Skip to content

Commit 5b37f2d

Browse files
authored
Merge pull request #191 from Digitro/completionHandler_for_reportNewIncomingCall
Add completionHandler for reportNewIncomingCall method
2 parents eacefd2 + 1b98744 commit 5b37f2d

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,7 @@ Since iOS 13, you'll have to report the incoming calls that wakes up your applic
673673
// NSString *handle = @"caller number here";
674674
// NSDictionary *extra = [payload.dictionaryPayload valueForKeyPath:@"custom.path.to.data"]; /* use this to pass any special data (ie. from your notification) down to RN. Can also be `nil` */
675675

676-
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:extra];
677-
678-
completion();
676+
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:extra withCompletionHandler:completion];
679677
}
680678
```
681679

ios/RNCallKeep/RNCallKeep.h

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ continueUserActivity:(NSUserActivity *)userActivity
3535
fromPushKit:(BOOL)fromPushKit
3636
payload:(NSDictionary * _Nullable)payload;
3737

38+
+ (void)reportNewIncomingCall:(NSString *)uuidString
39+
handle:(NSString *)handle
40+
handleType:(NSString *)handleType
41+
hasVideo:(BOOL)hasVideo
42+
localizedCallerName:(NSString * _Nullable)localizedCallerName
43+
fromPushKit:(BOOL)fromPushKit
44+
payload:(NSDictionary * _Nullable)payload
45+
withCompletionHandler:(void (^_Nullable)(void))completion;
46+
3847
+ (void)endCallWithUUID:(NSString *)uuidString
3948
reason:(int)reason;
4049
@end

ios/RNCallKeep/RNCallKeep.m

+17-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ + (void)initCallKitProvider {
151151
hasVideo:(BOOL)hasVideo
152152
localizedCallerName:(NSString * _Nullable)localizedCallerName)
153153
{
154-
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil];
154+
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil withCompletionHandler:nil];
155155
}
156156

157157
RCT_EXPORT_METHOD(startCall:(NSString *)uuidString
@@ -340,6 +340,18 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
340340
localizedCallerName:(NSString * _Nullable)localizedCallerName
341341
fromPushKit:(BOOL)fromPushKit
342342
payload:(NSDictionary * _Nullable)payload
343+
{
344+
[RNCallKeep reportNewIncomingCall:uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit:fromPushKit payload:payload withCompletionHandler:nil];
345+
}
346+
347+
+ (void)reportNewIncomingCall:(NSString *)uuidString
348+
handle:(NSString *)handle
349+
handleType:(NSString *)handleType
350+
hasVideo:(BOOL)hasVideo
351+
localizedCallerName:(NSString * _Nullable)localizedCallerName
352+
fromPushKit:(BOOL)fromPushKit
353+
payload:(NSDictionary * _Nullable)payload
354+
withCompletionHandler:(void (^_Nullable)(void))completion
343355
{
344356
#ifdef DEBUG
345357
NSLog(@"[RNCallKeep][reportNewIncomingCall] uuidString = %@", uuidString);
@@ -373,6 +385,9 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
373385
[callKeep configureAudioSession];
374386
}
375387
}
388+
if (completion != nil) {
389+
completion();
390+
}
376391
}];
377392
}
378393

@@ -383,7 +398,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
383398
localizedCallerName:(NSString * _Nullable)localizedCallerName
384399
fromPushKit:(BOOL)fromPushKit
385400
{
386-
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: fromPushKit payload:nil];
401+
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: fromPushKit payload:nil withCompletionHandler:nil];
387402
}
388403

389404
- (BOOL)lessThanIos10_2

0 commit comments

Comments
 (0)