Skip to content

Commit 307f6b2

Browse files
author
Ricardo Corrie
committed
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.
1 parent 9650b79 commit 307f6b2

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,9 @@ Since iOS 13, you'll have to report the incoming calls that wakes up your applic
631631
// NSString *uuid = /* fetch for payload or ... */ [[[NSUUID UUID] UUIDString] lowercaseString];
632632
// NSString *callerName = @"caller name here";
633633
// NSString *handle = @"caller number here";
634+
// 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` */
634635

635-
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES];
636+
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:extra];
636637

637638
completion();
638639
}

ios/RNCallKeep/RNCallKeep.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ continueUserActivity:(NSUserActivity *)userActivity
3232
handleType:(NSString *)handleType
3333
hasVideo:(BOOL)hasVideo
3434
localizedCallerName:(NSString * _Nullable)localizedCallerName
35-
fromPushKit:(BOOL)fromPushKit;
35+
fromPushKit:(BOOL)fromPushKit
36+
payload:(NSDictionary * _Nullable)payload;
3637
@end

ios/RNCallKeep/RNCallKeep.m

Lines changed: 3 additions & 2 deletions
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];
154+
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil];
155155
}
156156

157157
RCT_EXPORT_METHOD(startCall:(NSString *)uuidString
@@ -326,6 +326,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
326326
hasVideo:(BOOL)hasVideo
327327
localizedCallerName:(NSString * _Nullable)localizedCallerName
328328
fromPushKit:(BOOL)fromPushKit
329+
payload:(NSDictionary * _Nullable)payload
329330
{
330331
#ifdef DEBUG
331332
NSLog(@"[RNCallKeep][reportNewIncomingCall] uuidString = %@", uuidString);
@@ -344,7 +345,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
344345
[RNCallKeep initCallKitProvider];
345346
[sharedProvider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError * _Nullable error) {
346347
RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil];
347-
[callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"fromPushKit": fromPushKit ? @"1" : @"0" }];
348+
[callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"fromPushKit": fromPushKit ? @"1" : @"0", @"payload": payload }];
348349
if (error == nil) {
349350
// Workaround per https://forums.developer.apple.com/message/169511
350351
if ([callKeep lessThanIos10_2]) {

0 commit comments

Comments
 (0)