From 307f6b20f19c774f03cdd49e72eba173bd6dca01 Mon Sep 17 00:00:00 2001 From: Ricardo Corrie Date: Wed, 13 Nov 2019 20:27:45 -0500 Subject: [PATCH 1/2] This PR allows a developer to pass data received in the VoIP notification payload, down to the RN layer, when reporting a new incoming call. --- README.md | 3 ++- ios/RNCallKeep/RNCallKeep.h | 3 ++- ios/RNCallKeep/RNCallKeep.m | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 54d760ba..b63b6310 100644 --- a/README.md +++ b/README.md @@ -631,8 +631,9 @@ Since iOS 13, you'll have to report the incoming calls that wakes up your applic // NSString *uuid = /* fetch for payload or ... */ [[[NSUUID UUID] UUIDString] lowercaseString]; // NSString *callerName = @"caller name here"; // NSString *handle = @"caller number here"; + // 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` */ - [RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES]; + [RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:extra]; completion(); } diff --git a/ios/RNCallKeep/RNCallKeep.h b/ios/RNCallKeep/RNCallKeep.h index ffc19f28..d6d07c4e 100644 --- a/ios/RNCallKeep/RNCallKeep.h +++ b/ios/RNCallKeep/RNCallKeep.h @@ -32,5 +32,6 @@ continueUserActivity:(NSUserActivity *)userActivity handleType:(NSString *)handleType hasVideo:(BOOL)hasVideo localizedCallerName:(NSString * _Nullable)localizedCallerName - fromPushKit:(BOOL)fromPushKit; + fromPushKit:(BOOL)fromPushKit + payload:(NSDictionary * _Nullable)payload; @end diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 0fe8061a..50bdd80b 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -151,7 +151,7 @@ + (void)initCallKitProvider { hasVideo:(BOOL)hasVideo localizedCallerName:(NSString * _Nullable)localizedCallerName) { - [RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO]; + [RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil]; } RCT_EXPORT_METHOD(startCall:(NSString *)uuidString @@ -326,6 +326,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString hasVideo:(BOOL)hasVideo localizedCallerName:(NSString * _Nullable)localizedCallerName fromPushKit:(BOOL)fromPushKit + payload:(NSDictionary * _Nullable)payload { #ifdef DEBUG NSLog(@"[RNCallKeep][reportNewIncomingCall] uuidString = %@", uuidString); @@ -344,7 +345,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString [RNCallKeep initCallKitProvider]; [sharedProvider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError * _Nullable error) { RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil]; - [callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"fromPushKit": fromPushKit ? @"1" : @"0" }]; + [callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"fromPushKit": fromPushKit ? @"1" : @"0", @"payload": payload }]; if (error == nil) { // Workaround per https://forums.developer.apple.com/message/169511 if ([callKeep lessThanIos10_2]) { From e6a29d1228c3dcc0f8c3bc99ec4c7539dcf47ff3 Mon Sep 17 00:00:00 2001 From: Ricardo Corrie Date: Thu, 16 Jan 2020 16:01:33 -0500 Subject: [PATCH 2/2] `payload` parameter of `reportNewIncomingCall` method is now optional --- ios/RNCallKeep/RNCallKeep.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 9522accc..3a532588 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -362,6 +362,16 @@ + (void)reportNewIncomingCall:(NSString *)uuidString }]; } ++ (void)reportNewIncomingCall:(NSString *)uuidString + handle:(NSString *)handle + handleType:(NSString *)handleType + hasVideo:(BOOL)hasVideo + localizedCallerName:(NSString * _Nullable)localizedCallerName + fromPushKit:(BOOL)fromPushKit +{ + [RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil]; +} + - (BOOL)lessThanIos10_2 { if (_version.majorVersion < 10) {