22
22
static NSString *const RNCallKitPerformAnswerCallAction = @" RNCallKitPerformAnswerCallAction" ;
23
23
static NSString *const RNCallKitPerformEndCallAction = @" RNCallKitPerformEndCallAction" ;
24
24
static NSString *const RNCallKitDidActivateAudioSession = @" RNCallKitDidActivateAudioSession" ;
25
+ static NSString *const RNCallKitDidDisplayIncomingCall = @" RNCallKitDidDisplayIncomingCall" ;
25
26
26
27
@implementation RNCallKit
27
28
{
@@ -60,11 +61,12 @@ - (void)dealloc
60
61
- (NSArray <NSString *> *)supportedEvents
61
62
{
62
63
return @[
63
- RNCallKitDidReceiveStartCallAction,
64
- RNCallKitPerformAnswerCallAction,
65
- RNCallKitPerformEndCallAction,
66
- RNCallKitDidActivateAudioSession
67
- ];
64
+ RNCallKitDidReceiveStartCallAction,
65
+ RNCallKitPerformAnswerCallAction,
66
+ RNCallKitPerformEndCallAction,
67
+ RNCallKitDidActivateAudioSession,
68
+ RNCallKitDidDisplayIncomingCall
69
+ ];
68
70
}
69
71
70
72
RCT_EXPORT_METHOD (setup:(NSDictionary *)options)
@@ -83,9 +85,9 @@ - (void)dealloc
83
85
84
86
// Display the incoming call to the user
85
87
RCT_EXPORT_METHOD (displayIncomingCall:(NSString *)uuidString
86
- handle:(NSString *)handle
87
- handleType:(NSString *)handleType
88
- hasVideo:(BOOL )hasVideo
88
+ handle:(NSString *)handle
89
+ handleType:(NSString *)handleType
90
+ hasVideo:(BOOL )hasVideo
89
91
localizedCallerName:(NSString * _Nullable)localizedCallerName)
90
92
{
91
93
#ifdef DEBUG
@@ -104,6 +106,8 @@ - (void)dealloc
104
106
callUpdate.localizedCallerName = localizedCallerName;
105
107
106
108
[self .callKitProvider reportNewIncomingCallWithUUID: uuid update: callUpdate completion: ^(NSError * _Nullable error) {
109
+ // Invoking the displayIncomingCall callback
110
+ [self sendEventWithName: RNCallKitDidDisplayIncomingCall body: @{ @" error" : error ? error.localizedDescription : @" " }];
107
111
if (error == nil ) {
108
112
// Workaround per https://forums.developer.apple.com/message/169511
109
113
if ([self lessThanIos10_2 ]) {
@@ -291,25 +295,25 @@ + (BOOL)application:(UIApplication *)application
291
295
NSLog (@" [RNCallKit][application:openURL]" );
292
296
#endif
293
297
/*
294
- NSString *handle = [url startCallHandle];
295
- if (handle != nil && handle.length > 0 ){
296
- NSDictionary *userInfo = @{
297
- @"handle": handle,
298
- @"video": @NO
299
- };
300
- [[NSNotificationCenter defaultCenter] postNotificationName:RNCallKitHandleStartCallNotification
301
- object:self
302
- userInfo:userInfo];
303
- return YES;
304
- }
305
- return NO;
306
- */
298
+ NSString *handle = [url startCallHandle];
299
+ if (handle != nil && handle.length > 0 ){
300
+ NSDictionary *userInfo = @{
301
+ @"handle": handle,
302
+ @"video": @NO
303
+ };
304
+ [[NSNotificationCenter defaultCenter] postNotificationName:RNCallKitHandleStartCallNotification
305
+ object:self
306
+ userInfo:userInfo];
307
+ return YES;
308
+ }
309
+ return NO;
310
+ */
307
311
return YES ;
308
312
}
309
313
310
314
+ (BOOL )application : (UIApplication *)application
311
315
continueUserActivity : (NSUserActivity *)userActivity
312
- restorationHandler : (void (^)(NSArray * __nullable restorableObjects))restorationHandler
316
+ restorationHandler : (void (^)(NSArray * __nullable restorableObjects))restorationHandler
313
317
{
314
318
#ifdef DEBUG
315
319
NSLog (@" [RNCallKit][application:continueUserActivity]" );
@@ -319,25 +323,25 @@ + (BOOL)application:(UIApplication *)application
319
323
NSString *handle;
320
324
BOOL isAudioCall = [userActivity.activityType isEqualToString: INStartAudioCallIntentIdentifier];
321
325
BOOL isVideoCall = [userActivity.activityType isEqualToString: INStartVideoCallIntentIdentifier];
322
-
326
+
323
327
if (isAudioCall) {
324
328
INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent ;
325
329
contact = [startAudioCallIntent.contacts firstObject ];
326
330
} else if (isVideoCall) {
327
331
INStartVideoCallIntent *startVideoCallIntent = (INStartVideoCallIntent *)interaction.intent ;
328
332
contact = [startVideoCallIntent.contacts firstObject ];
329
333
}
330
-
334
+
331
335
if (contact != nil ) {
332
336
handle = contact.personHandle .value ;
333
337
}
334
-
338
+
335
339
if (handle != nil && handle.length > 0 ){
336
340
NSDictionary *userInfo = @{
337
341
@" handle" : handle,
338
342
@" video" : @(isVideoCall)
339
343
};
340
-
344
+
341
345
[[NSNotificationCenter defaultCenter ] postNotificationName: RNCallKitHandleStartCallNotification
342
346
object: self
343
347
userInfo: userInfo];
0 commit comments