Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4ba799d

Browse files
authoredMar 10, 2020
Merge pull request #149 from coretech/notification-payload
Pass data from VoIP Notification down to RN
2 parents d5ead32 + e6a29d1 commit 4ba799d

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed
 

‎README.md

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

668-
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES];
669+
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:extra];
669670

670671
completion();
671672
}

‎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: 13 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
@@ -333,6 +333,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
333333
hasVideo:(BOOL)hasVideo
334334
localizedCallerName:(NSString * _Nullable)localizedCallerName
335335
fromPushKit:(BOOL)fromPushKit
336+
payload:(NSDictionary * _Nullable)payload
336337
{
337338
#ifdef DEBUG
338339
NSLog(@"[RNCallKeep][reportNewIncomingCall] uuidString = %@", uuidString);
@@ -351,7 +352,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
351352
[RNCallKeep initCallKitProvider];
352353
[sharedProvider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError * _Nullable error) {
353354
RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil];
354-
[callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"hasVideo": hasVideo ? @"1" : @"0", @"fromPushKit": fromPushKit ? @"1" : @"0" }];
355+
[callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"hasVideo": hasVideo ? @"1" : @"0", @"fromPushKit": fromPushKit ? @"1" : @"0", @"payload": payload }];
355356
if (error == nil) {
356357
// Workaround per https://forums.developer.apple.com/message/169511
357358
if ([callKeep lessThanIos10_2]) {
@@ -361,6 +362,16 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
361362
}];
362363
}
363364

365+
+ (void)reportNewIncomingCall:(NSString *)uuidString
366+
handle:(NSString *)handle
367+
handleType:(NSString *)handleType
368+
hasVideo:(BOOL)hasVideo
369+
localizedCallerName:(NSString * _Nullable)localizedCallerName
370+
fromPushKit:(BOOL)fromPushKit
371+
{
372+
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil];
373+
}
374+
364375
- (BOOL)lessThanIos10_2
365376
{
366377
if (_version.majorVersion < 10) {

0 commit comments

Comments
 (0)
Please sign in to comment.