2222static NSString *const RNCallKitPerformAnswerCallAction = @" RNCallKitPerformAnswerCallAction" ;
2323static NSString *const RNCallKitPerformEndCallAction = @" RNCallKitPerformEndCallAction" ;
2424static NSString *const RNCallKitDidActivateAudioSession = @" RNCallKitDidActivateAudioSession" ;
25+ static NSString *const RNCallKitDidDisplayIncomingCall = @" RNCallKitDidDisplayIncomingCall" ;
2526
2627@implementation RNCallKit
2728{
@@ -60,11 +61,12 @@ - (void)dealloc
6061- (NSArray <NSString *> *)supportedEvents
6162{
6263 return @[
63- RNCallKitDidReceiveStartCallAction,
64- RNCallKitPerformAnswerCallAction,
65- RNCallKitPerformEndCallAction,
66- RNCallKitDidActivateAudioSession
67- ];
64+ RNCallKitDidReceiveStartCallAction,
65+ RNCallKitPerformAnswerCallAction,
66+ RNCallKitPerformEndCallAction,
67+ RNCallKitDidActivateAudioSession,
68+ RNCallKitDidDisplayIncomingCall
69+ ];
6870}
6971
7072RCT_EXPORT_METHOD (setup:(NSDictionary *)options)
@@ -83,9 +85,9 @@ - (void)dealloc
8385
8486// Display the incoming call to the user
8587RCT_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
8991 localizedCallerName:(NSString * _Nullable)localizedCallerName)
9092{
9193#ifdef DEBUG
@@ -104,6 +106,8 @@ - (void)dealloc
104106 callUpdate.localizedCallerName = localizedCallerName;
105107
106108 [self .callKitProvider reportNewIncomingCallWithUUID: uuid update: callUpdate completion: ^(NSError * _Nullable error) {
109+ // Invoking the displayIncomingCall callback
110+ [self sendEventWithName: RNCallKitDidDisplayIncomingCall body: @{ @" error" : error ? error.localizedDescription : @" " }];
107111 if (error == nil ) {
108112 // Workaround per https://forums.developer.apple.com/message/169511
109113 if ([self lessThanIos10_2 ]) {
@@ -291,25 +295,25 @@ + (BOOL)application:(UIApplication *)application
291295 NSLog (@" [RNCallKit][application:openURL]" );
292296#endif
293297 /*
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+ */
307311 return YES ;
308312}
309313
310314+ (BOOL )application : (UIApplication *)application
311315continueUserActivity : (NSUserActivity *)userActivity
312- restorationHandler : (void (^)(NSArray * __nullable restorableObjects))restorationHandler
316+ restorationHandler : (void (^)(NSArray * __nullable restorableObjects))restorationHandler
313317{
314318#ifdef DEBUG
315319 NSLog (@" [RNCallKit][application:continueUserActivity]" );
@@ -319,25 +323,25 @@ + (BOOL)application:(UIApplication *)application
319323 NSString *handle;
320324 BOOL isAudioCall = [userActivity.activityType isEqualToString: INStartAudioCallIntentIdentifier];
321325 BOOL isVideoCall = [userActivity.activityType isEqualToString: INStartVideoCallIntentIdentifier];
322-
326+
323327 if (isAudioCall) {
324328 INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent ;
325329 contact = [startAudioCallIntent.contacts firstObject ];
326330 } else if (isVideoCall) {
327331 INStartVideoCallIntent *startVideoCallIntent = (INStartVideoCallIntent *)interaction.intent ;
328332 contact = [startVideoCallIntent.contacts firstObject ];
329333 }
330-
334+
331335 if (contact != nil ) {
332336 handle = contact.personHandle .value ;
333337 }
334-
338+
335339 if (handle != nil && handle.length > 0 ){
336340 NSDictionary *userInfo = @{
337341 @" handle" : handle,
338342 @" video" : @(isVideoCall)
339343 };
340-
344+
341345 [[NSNotificationCenter defaultCenter ] postNotificationName: RNCallKitHandleStartCallNotification
342346 object: self
343347 userInfo: userInfo];
0 commit comments