Skip to content

Commit c73229d

Browse files
authored
Merge branch 'master' into master
2 parents bfa630d + 0028869 commit c73229d

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ RNCallKeep.addEventListener('didActivateAudioSession', () => {
441441
Callback for `RNCallKeep.displayIncomingCall`
442442

443443
```js
444-
RNCallKeep.addEventListener('didDisplayIncomingCall', ({ error, callUUID, handle, localizedCallerName, hasVideo, fromPushKit }) => {
444+
RNCallKeep.addEventListener('didDisplayIncomingCall', ({ error, callUUID, handle, localizedCallerName, hasVideo, fromPushKit, payload }) => {
445445
// you might want to do following things when receiving this event:
446446
// - Start playing ringback if it is an outgoing call
447447
});
@@ -461,6 +461,8 @@ RNCallKeep.addEventListener('didDisplayIncomingCall', ({ error, callUUID, handle
461461
- `fromPushKit` (string)
462462
- `1` (call triggered from PushKit)
463463
- `0` (call not triggered from PushKit)
464+
- `didDisplayIncomingCall` (object)
465+
- VOIP push payload.
464466

465467
### - didPerformSetMutedCallAction
466468

@@ -664,8 +666,9 @@ Since iOS 13, you'll have to report the incoming calls that wakes up your applic
664666
// NSString *uuid = /* fetch for payload or ... */ [[[NSUUID UUID] UUIDString] lowercaseString];
665667
// NSString *callerName = @"caller name here";
666668
// NSString *handle = @"caller number here";
669+
// 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` */
667670

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

670673
completion();
671674
}

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type Events =
1+
export type Events =
22
'didReceiveStartCallAction' |
33
'answerCall' |
44
'endCall' |

ios/RNCallKeep/RNCallKeep.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ 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

3738
+ (void)endCallWithUUID:(NSString *)uuidString
3839
reason:(int)reason;
39-
40-
@end
40+
@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
@@ -339,6 +339,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
339339
hasVideo:(BOOL)hasVideo
340340
localizedCallerName:(NSString * _Nullable)localizedCallerName
341341
fromPushKit:(BOOL)fromPushKit
342+
payload:(NSDictionary * _Nullable)payload
342343
{
343344
#ifdef DEBUG
344345
NSLog(@"[RNCallKeep][reportNewIncomingCall] uuidString = %@", uuidString);
@@ -357,7 +358,7 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
357358
[RNCallKeep initCallKitProvider];
358359
[sharedProvider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError * _Nullable error) {
359360
RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil];
360-
[callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"hasVideo": hasVideo ? @"1" : @"0", @"fromPushKit": fromPushKit ? @"1" : @"0" }];
361+
[callKeep sendEventWithName:RNCallKeepDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"", @"callUUID": uuidString, @"handle": handle, @"localizedCallerName": localizedCallerName, @"hasVideo": hasVideo ? @"1" : @"0", @"fromPushKit": fromPushKit ? @"1" : @"0", @"payload": payload }];
361362
if (error == nil) {
362363
// Workaround per https://forums.developer.apple.com/message/169511
363364
if ([callKeep lessThanIos10_2]) {
@@ -367,6 +368,16 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
367368
}];
368369
}
369370

371+
+ (void)reportNewIncomingCall:(NSString *)uuidString
372+
handle:(NSString *)handle
373+
handleType:(NSString *)handleType
374+
hasVideo:(BOOL)hasVideo
375+
localizedCallerName:(NSString * _Nullable)localizedCallerName
376+
fromPushKit:(BOOL)fromPushKit
377+
{
378+
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil];
379+
}
380+
370381
- (BOOL)lessThanIos10_2
371382
{
372383
if (_version.majorVersion < 10) {

0 commit comments

Comments
 (0)