rns-nativecall 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/CallModule.m +10 -10
- package/package.json +1 -1
package/ios/CallModule.m
CHANGED
|
@@ -21,6 +21,7 @@ RCT_EXPORT_MODULE();
|
|
|
21
21
|
config.supportsVideo = YES;
|
|
22
22
|
config.maximumCallGroups = 1;
|
|
23
23
|
config.maximumCallsPerCallGroup = 1;
|
|
24
|
+
config.includesCallsInRecents = NO;
|
|
24
25
|
config.supportedHandleTypes = [NSSet setWithObject:@(CXHandleTypeGeneric)];
|
|
25
26
|
|
|
26
27
|
self.provider = [[CXProvider alloc] initWithConfiguration:config];
|
|
@@ -43,11 +44,11 @@ RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)uuidString
|
|
|
43
44
|
|
|
44
45
|
self.currentCallUUID = uuid;
|
|
45
46
|
|
|
46
|
-
// 1. CONFIGURE AUDIO SESSION
|
|
47
|
+
// 1. CONFIGURE AUDIO SESSION (Pre-warm)
|
|
47
48
|
AVAudioSession *session = [AVAudioSession sharedInstance];
|
|
48
49
|
[session setCategory:AVAudioSessionCategoryPlayAndRecord
|
|
49
50
|
mode:AVAudioSessionModeVoiceChat
|
|
50
|
-
options:AVAudioSessionCategoryOptionAllowBluetooth
|
|
51
|
+
options:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker
|
|
51
52
|
error:nil];
|
|
52
53
|
|
|
53
54
|
CXCallUpdate *update = [[CXCallUpdate alloc] init];
|
|
@@ -63,24 +64,17 @@ RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)uuidString
|
|
|
63
64
|
}];
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
/**
|
|
67
|
-
* EXPOSED METHOD: endNativeCall
|
|
68
|
-
* Use this to dismiss the UI if the caller hangs up (Remote Ended)
|
|
69
|
-
*/
|
|
70
67
|
RCT_EXPORT_METHOD(endNativeCall:(NSString *)uuidString)
|
|
71
68
|
{
|
|
72
69
|
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
|
|
73
70
|
if (!uuid) return;
|
|
74
71
|
|
|
75
|
-
// Report to CallKit that the remote user ended the call
|
|
76
72
|
[self.provider reportCallWithUUID:uuid
|
|
77
73
|
endedAtDate:[NSDate date]
|
|
78
74
|
reason:CXCallEndedReasonRemoteEnded];
|
|
79
|
-
|
|
80
75
|
self.currentCallUUID = nil;
|
|
81
76
|
}
|
|
82
77
|
|
|
83
|
-
// Parity methods for JS
|
|
84
78
|
RCT_EXPORT_METHOD(getInitialCallData:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
85
79
|
resolve([NSNull null]);
|
|
86
80
|
}
|
|
@@ -92,13 +86,19 @@ RCT_EXPORT_METHOD(checkTelecomPermissions:(RCTPromiseResolveBlock)resolve reject
|
|
|
92
86
|
// MARK: - CXProviderDelegate
|
|
93
87
|
|
|
94
88
|
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
|
|
89
|
+
// 1. Activate Audio Session
|
|
90
|
+
// This transition tells iOS the app is now the active audio owner, which triggers the foregrounding
|
|
95
91
|
[[AVAudioSession sharedInstance] setActive:YES error:nil];
|
|
92
|
+
|
|
93
|
+
// 2. Fulfill the action
|
|
96
94
|
[action fulfill];
|
|
95
|
+
|
|
96
|
+
// 3. Notify JavaScript
|
|
97
|
+
// Once JS receives this, the navigationRef in App.js handles the UI transition
|
|
97
98
|
[self sendEventWithName:@"onCallAccepted" body:@{@"callUuid": [action.callUUID.UUIDString lowercaseString]}];
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action {
|
|
101
|
-
// This fires when the user taps "Decline" on the lock screen
|
|
102
102
|
[action fulfill];
|
|
103
103
|
self.currentCallUUID = nil;
|
|
104
104
|
[self sendEventWithName:@"onCallRejected" body:@{@"callUuid": [action.callUUID.UUIDString lowercaseString]}];
|
package/package.json
CHANGED