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)
@@ -104,6 +106,7 @@ - (void)dealloc
104
106
callUpdate.localizedCallerName = localizedCallerName;
105
107
106
108
[self .callKitProvider reportNewIncomingCallWithUUID: uuid update: callUpdate completion: ^(NSError * _Nullable error) {
109
+ [self sendEventWithName: RNCallKitDidDisplayIncomingCall body: @{ @" error" : error ? error.localizedDescription : @" " }];
107
110
if (error == nil ) {
108
111
// Workaround per https://forums.developer.apple.com/message/169511
109
112
if ([self lessThanIos10_2 ]) {
@@ -309,7 +312,7 @@ + (BOOL)application:(UIApplication *)application
309
312
310
313
+ (BOOL )application : (UIApplication *)application
311
314
continueUserActivity : (NSUserActivity *)userActivity
312
- restorationHandler : (void (^)(NSArray * __nullable restorableObjects))restorationHandler
315
+ restorationHandler : (void (^)(NSArray * __nullable restorableObjects))restorationHandler
313
316
{
314
317
#ifdef DEBUG
315
318
NSLog (@" [RNCallKit][application:continueUserActivity]" );
@@ -319,25 +322,25 @@ + (BOOL)application:(UIApplication *)application
319
322
NSString *handle;
320
323
BOOL isAudioCall = [userActivity.activityType isEqualToString: INStartAudioCallIntentIdentifier];
321
324
BOOL isVideoCall = [userActivity.activityType isEqualToString: INStartVideoCallIntentIdentifier];
322
-
325
+
323
326
if (isAudioCall) {
324
327
INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent ;
325
328
contact = [startAudioCallIntent.contacts firstObject ];
326
329
} else if (isVideoCall) {
327
330
INStartVideoCallIntent *startVideoCallIntent = (INStartVideoCallIntent *)interaction.intent ;
328
331
contact = [startVideoCallIntent.contacts firstObject ];
329
332
}
330
-
333
+
331
334
if (contact != nil ) {
332
335
handle = contact.personHandle .value ;
333
336
}
334
-
337
+
335
338
if (handle != nil && handle.length > 0 ){
336
339
NSDictionary *userInfo = @{
337
340
@" handle" : handle,
338
341
@" video" : @(isVideoCall)
339
342
};
340
-
343
+
341
344
[[NSNotificationCenter defaultCenter ] postNotificationName: RNCallKitHandleStartCallNotification
342
345
object: self
343
346
userInfo: userInfo];
0 commit comments