@@ -41,6 +41,7 @@ @implementation RNCallKeep
41
41
BOOL _isStartCallActionEventListenerAdded;
42
42
bool _hasListeners;
43
43
NSMutableArray *_delayedEvents;
44
+ bool _isSetup;
44
45
}
45
46
46
47
static CXProvider * sharedProvider;
@@ -54,8 +55,10 @@ - (instancetype)init
54
55
NSLog (@" [RNCallKeep][init]" );
55
56
#endif
56
57
if (self = [super init ]) {
57
- _isStartCallActionEventListenerAdded = NO ;
58
- _delayedEvents = [NSMutableArray array ];
58
+ if (_delayedEvents == nil ) {
59
+ _isStartCallActionEventListenerAdded = NO ;
60
+ _delayedEvents = [NSMutableArray array ];
61
+ }
59
62
}
60
63
return self;
61
64
}
@@ -118,10 +121,10 @@ - (void)sendEventWithNameWrapper:(NSString *)name body:(id)body {
118
121
if (_hasListeners) {
119
122
[self sendEventWithName: name body: body];
120
123
} else {
121
- NSDictionary *dictionary = @{
122
- @" name" : name ,
123
- @" data" : body
124
- } ;
124
+ NSDictionary *dictionary = [ NSDictionary dictionaryWithObjectsAndKeys:
125
+ name, @" name" ,
126
+ body, @" data" ,
127
+ nil ] ;
125
128
[_delayedEvents addObject: dictionary];
126
129
}
127
130
}
@@ -133,8 +136,20 @@ + (void)initCallKitProvider {
133
136
}
134
137
}
135
138
139
+ + (void )setup : (NSDictionary *)options {
140
+ RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil ];
141
+ [callKeep setup: options];
142
+ }
143
+
136
144
RCT_EXPORT_METHOD (setup:(NSDictionary *)options)
137
145
{
146
+ if (_isSetup) {
147
+ #ifdef DEBUG
148
+ NSLog (@" [RNCallKeep][setup] already setup" );
149
+ #endif
150
+ return ;
151
+ }
152
+
138
153
#ifdef DEBUG
139
154
NSLog (@" [RNCallKeep][setup] options = %@ " , options);
140
155
#endif
@@ -149,6 +164,8 @@ + (void)initCallKitProvider {
149
164
150
165
self.callKeepProvider = sharedProvider;
151
166
[self .callKeepProvider setDelegate: self queue: nil ];
167
+
168
+ _isSetup = YES ;
152
169
}
153
170
154
171
RCT_REMAP_METHOD (checkIfBusy,
@@ -183,7 +200,7 @@ + (void)initCallKitProvider {
183
200
supportsHolding:(BOOL )supportsHolding
184
201
supportsDTMF:(BOOL )supportsDTMF
185
202
supportsGrouping:(BOOL )supportsGrouping
186
- supportsUngrouping:(BOOL )supportsUngrouping)
203
+ supportsUngrouping:(BOOL )supportsUngrouping)
187
204
{
188
205
[RNCallKeep reportNewIncomingCall: uuidString
189
206
handle: handle
0 commit comments