Skip to content

Commit 19413af

Browse files
committed
Implemented support for setup in AppDelegate
1 parent 5a29880 commit 19413af

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

ios/RNCallKeep/RNCallKeep.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ continueUserActivity:(NSUserActivity *)userActivity
4545

4646
+ (BOOL)isCallActive:(NSString *)uuidString;
4747

48+
+ (void)setup:(NSDictionary *)options;
49+
4850
@end

ios/RNCallKeep/RNCallKeep.m

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ @implementation RNCallKeep
4141
BOOL _isStartCallActionEventListenerAdded;
4242
bool _hasListeners;
4343
NSMutableArray *_delayedEvents;
44+
bool _isSetup;
4445
}
4546

4647
static CXProvider* sharedProvider;
@@ -54,8 +55,10 @@ - (instancetype)init
5455
NSLog(@"[RNCallKeep][init]");
5556
#endif
5657
if (self = [super init]) {
57-
_isStartCallActionEventListenerAdded = NO;
58-
_delayedEvents = [NSMutableArray array];
58+
if (_delayedEvents == nil) {
59+
_isStartCallActionEventListenerAdded = NO;
60+
_delayedEvents = [NSMutableArray array];
61+
}
5962
}
6063
return self;
6164
}
@@ -118,10 +121,10 @@ - (void)sendEventWithNameWrapper:(NSString *)name body:(id)body {
118121
if (_hasListeners) {
119122
[self sendEventWithName:name body:body];
120123
} else {
121-
NSDictionary *dictionary = @{
122-
@"name": name,
123-
@"data": body
124-
};
124+
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
125+
name, @"name",
126+
body, @"data",
127+
nil];
125128
[_delayedEvents addObject:dictionary];
126129
}
127130
}
@@ -133,8 +136,20 @@ + (void)initCallKitProvider {
133136
}
134137
}
135138

139+
+ (void)setup:(NSDictionary *)options {
140+
RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil];
141+
[callKeep setup:options];
142+
}
143+
136144
RCT_EXPORT_METHOD(setup:(NSDictionary *)options)
137145
{
146+
if (_isSetup) {
147+
#ifdef DEBUG
148+
NSLog(@"[RNCallKeep][setup] already setup");
149+
#endif
150+
return;
151+
}
152+
138153
#ifdef DEBUG
139154
NSLog(@"[RNCallKeep][setup] options = %@", options);
140155
#endif
@@ -149,6 +164,8 @@ + (void)initCallKitProvider {
149164

150165
self.callKeepProvider = sharedProvider;
151166
[self.callKeepProvider setDelegate:self queue:nil];
167+
168+
_isSetup = YES;
152169
}
153170

154171
RCT_REMAP_METHOD(checkIfBusy,
@@ -183,7 +200,7 @@ + (void)initCallKitProvider {
183200
supportsHolding:(BOOL)supportsHolding
184201
supportsDTMF:(BOOL)supportsDTMF
185202
supportsGrouping:(BOOL)supportsGrouping
186-
supportsUngrouping:(BOOL)supportsUngrouping)
203+
supportsUngrouping:(BOOL)supportsUngrouping)
187204
{
188205
[RNCallKeep reportNewIncomingCall: uuidString
189206
handle: handle

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-callkeep",
3-
"version": "4.1.0",
3+
"version": "4.1.1-iosfix",
44
"description": "iOS 10 CallKit and Android ConnectionService Framework For React Native",
55
"main": "index.js",
66
"scripts": {},

0 commit comments

Comments
 (0)