rns-nativecall 0.1.9 → 0.2.0
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 +30 -10
- package/package.json +1 -1
package/ios/CallModule.m
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
RCT_EXPORT_MODULE();
|
|
6
6
|
|
|
7
|
-
// Crucial: This keeps the module alive and on the main thread
|
|
8
7
|
+ (BOOL)requiresMainQueueSetup {
|
|
9
8
|
return YES;
|
|
10
9
|
}
|
|
@@ -23,9 +22,7 @@ RCT_EXPORT_MODULE();
|
|
|
23
22
|
config.maximumCallGroups = 1;
|
|
24
23
|
config.maximumCallsPerCallGroup = 1;
|
|
25
24
|
config.supportedHandleTypes = [NSSet setWithObject:@(CXHandleTypeGeneric)];
|
|
26
|
-
|
|
27
|
-
config.ringtoneSound = @"Ringtone.caf";
|
|
28
|
-
|
|
25
|
+
|
|
29
26
|
self.provider = [[CXProvider alloc] initWithConfiguration:config];
|
|
30
27
|
[self.provider setDelegate:self queue:nil];
|
|
31
28
|
}
|
|
@@ -46,13 +43,12 @@ RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)uuidString
|
|
|
46
43
|
|
|
47
44
|
self.currentCallUUID = uuid;
|
|
48
45
|
|
|
49
|
-
// 1. CONFIGURE AUDIO SESSION
|
|
46
|
+
// 1. CONFIGURE AUDIO SESSION
|
|
50
47
|
AVAudioSession *session = [AVAudioSession sharedInstance];
|
|
51
|
-
NSError *error = nil;
|
|
52
48
|
[session setCategory:AVAudioSessionCategoryPlayAndRecord
|
|
53
49
|
mode:AVAudioSessionModeVoiceChat
|
|
54
50
|
options:AVAudioSessionCategoryOptionAllowBluetooth
|
|
55
|
-
error
|
|
51
|
+
error:nil];
|
|
56
52
|
|
|
57
53
|
CXCallUpdate *update = [[CXCallUpdate alloc] init];
|
|
58
54
|
update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:name];
|
|
@@ -67,24 +63,48 @@ RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)uuidString
|
|
|
67
63
|
}];
|
|
68
64
|
}
|
|
69
65
|
|
|
66
|
+
/**
|
|
67
|
+
* EXPOSED METHOD: endNativeCall
|
|
68
|
+
* Use this to dismiss the UI if the caller hangs up (Remote Ended)
|
|
69
|
+
*/
|
|
70
|
+
RCT_EXPORT_METHOD(endNativeCall:(NSString *)uuidString)
|
|
71
|
+
{
|
|
72
|
+
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
|
|
73
|
+
if (!uuid) return;
|
|
74
|
+
|
|
75
|
+
// Report to CallKit that the remote user ended the call
|
|
76
|
+
[self.provider reportCallWithUUID:uuid
|
|
77
|
+
endedAtDate:[NSDate date]
|
|
78
|
+
reason:CXCallEndedReasonRemoteEnded];
|
|
79
|
+
|
|
80
|
+
self.currentCallUUID = nil;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Parity methods for JS
|
|
84
|
+
RCT_EXPORT_METHOD(getInitialCallData:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
85
|
+
resolve([NSNull null]);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
RCT_EXPORT_METHOD(checkTelecomPermissions:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
89
|
+
resolve(@YES);
|
|
90
|
+
}
|
|
91
|
+
|
|
70
92
|
// MARK: - CXProviderDelegate
|
|
71
93
|
|
|
72
94
|
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
|
|
73
|
-
// 2. ACTIVATE AUDIO SESSION (Crucial for CallKit)
|
|
74
95
|
[[AVAudioSession sharedInstance] setActive:YES error:nil];
|
|
75
|
-
|
|
76
96
|
[action fulfill];
|
|
77
97
|
[self sendEventWithName:@"onCallAccepted" body:@{@"callUuid": [action.callUUID.UUIDString lowercaseString]}];
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action {
|
|
101
|
+
// This fires when the user taps "Decline" on the lock screen
|
|
81
102
|
[action fulfill];
|
|
82
103
|
self.currentCallUUID = nil;
|
|
83
104
|
[self sendEventWithName:@"onCallRejected" body:@{@"callUuid": [action.callUUID.UUIDString lowercaseString]}];
|
|
84
105
|
}
|
|
85
106
|
|
|
86
107
|
- (void)providerDidReset:(CXProvider *)provider {
|
|
87
|
-
// Stop all audio if provider resets
|
|
88
108
|
[[AVAudioSession sharedInstance] setActive:NO error:nil];
|
|
89
109
|
}
|
|
90
110
|
|
package/package.json
CHANGED