@stream-io/react-native-callingx 0.1.0-beta.5 → 0.1.0-beta.6
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/android/build.gradle +9 -0
- package/android/src/main/java/io/getstream/rn/callingx/CallService.kt +28 -43
- package/android/src/main/java/io/getstream/rn/callingx/CallingxEventEmitterAdapter.kt +7 -0
- package/android/src/main/java/io/getstream/rn/callingx/{CallingxModule.kt → CallingxModuleImpl.kt} +53 -51
- package/android/src/main/java/io/getstream/rn/callingx/notifications/CallNotificationManager.kt +9 -9
- package/android/src/main/java/io/getstream/rn/callingx/notifications/NotificationIntentFactory.kt +8 -8
- package/android/src/main/java/io/getstream/rn/callingx/notifications/NotificationReceiverActivity.kt +7 -7
- package/android/src/main/java/io/getstream/rn/callingx/notifications/NotificationReceiverService.kt +7 -7
- package/android/src/newarch/java/io/getstream/rn/callingx/CallingxModule.kt +148 -0
- package/android/src/oldarch/java/io/getstream/rn/callingx/CallingxModule.kt +177 -0
- package/android/src/oldarch/java/io/getstream/rn/callingx/CallingxPackage.kt +16 -0
- package/dist/module/EventManager.js +11 -4
- package/dist/module/EventManager.js.map +1 -1
- package/dist/module/spec/NativeCallingx.js +4 -2
- package/dist/module/spec/NativeCallingx.js.map +1 -1
- package/dist/module/utils/utils.js +3 -0
- package/dist/module/utils/utils.js.map +1 -1
- package/dist/typescript/src/EventManager.d.ts.map +1 -1
- package/dist/typescript/src/spec/NativeCallingx.d.ts +2 -2
- package/dist/typescript/src/spec/NativeCallingx.d.ts.map +1 -1
- package/dist/typescript/src/utils/utils.d.ts +1 -0
- package/dist/typescript/src/utils/utils.d.ts.map +1 -1
- package/ios/Callingx.mm +312 -18
- package/package.json +1 -1
- package/src/EventManager.ts +18 -5
- package/src/spec/NativeCallingx.ts +11 -2
- package/src/utils/utils.ts +3 -0
- /package/android/src/{main → newarch}/java/io/getstream/rn/callingx/CallingxPackage.kt +0 -0
package/ios/Callingx.mm
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
1
2
|
#import <CallingxSpec/CallingxSpec.h>
|
|
3
|
+
#endif
|
|
4
|
+
|
|
5
|
+
#import <React/RCTBridgeModule.h>
|
|
6
|
+
#import <React/RCTEventEmitter.h>
|
|
2
7
|
#import <React/RCTBridge+Private.h>
|
|
3
8
|
|
|
4
9
|
#import <AVFoundation/AVAudioSession.h>
|
|
@@ -12,9 +17,13 @@
|
|
|
12
17
|
#import <Callingx/Callingx-Swift.h>
|
|
13
18
|
#endif
|
|
14
19
|
|
|
15
|
-
// MARK: - Callingx
|
|
20
|
+
// MARK: - Callingx Interface
|
|
16
21
|
|
|
22
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
17
23
|
@interface Callingx : NativeCallingxSpecBase<NativeCallingxSpec, CallingxEventEmitter, VoipNotificationsEventEmitter>
|
|
24
|
+
#else
|
|
25
|
+
@interface Callingx : RCTEventEmitter <RCTBridgeModule, CallingxEventEmitter, VoipNotificationsEventEmitter>
|
|
26
|
+
#endif
|
|
18
27
|
|
|
19
28
|
@property (nonatomic, strong) CXCallController *callKeepCallController;
|
|
20
29
|
@property (nonatomic, strong) CXProvider *callKeepProvider;
|
|
@@ -36,15 +45,21 @@
|
|
|
36
45
|
return sharedInstance;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
#pragma mark -
|
|
48
|
+
#pragma mark - Module Registration
|
|
40
49
|
|
|
41
50
|
+ (BOOL)requiresMainQueueSetup {
|
|
42
51
|
return YES;
|
|
43
52
|
}
|
|
44
53
|
|
|
54
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
45
55
|
+ (NSString *)moduleName {
|
|
46
56
|
return @"Callingx";
|
|
47
57
|
}
|
|
58
|
+
#else
|
|
59
|
+
RCT_EXPORT_MODULE(Callingx)
|
|
60
|
+
#endif
|
|
61
|
+
|
|
62
|
+
#pragma mark - Class Methods (Public API)
|
|
48
63
|
|
|
49
64
|
+ (void)reportNewIncomingCall:(NSString *)callId
|
|
50
65
|
handle:(NSString *)handle
|
|
@@ -57,7 +72,7 @@
|
|
|
57
72
|
supportsUngrouping:(BOOL)supportsUngrouping
|
|
58
73
|
payload:(NSDictionary *_Nullable)payload
|
|
59
74
|
withCompletionHandler:(void (^_Nullable)(void))completion {
|
|
60
|
-
|
|
75
|
+
|
|
61
76
|
[CallingxImpl reportNewIncomingCallWithCallId:callId
|
|
62
77
|
handle:handle
|
|
63
78
|
handleType:handleType
|
|
@@ -98,23 +113,59 @@
|
|
|
98
113
|
_moduleImpl = nil;
|
|
99
114
|
}
|
|
100
115
|
|
|
116
|
+
#pragma mark - Old Arch Event Support
|
|
117
|
+
|
|
118
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
119
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
120
|
+
return @[@"onNewEvent", @"onNewVoipEvent"];
|
|
121
|
+
}
|
|
122
|
+
#endif
|
|
123
|
+
|
|
124
|
+
#pragma mark - Turbo Module (New Arch Only)
|
|
125
|
+
|
|
126
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
101
127
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
102
128
|
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
103
129
|
return std::make_shared<facebook::react::NativeCallingxSpecJSI>(params);
|
|
104
130
|
}
|
|
131
|
+
#endif
|
|
105
132
|
|
|
106
|
-
#pragma mark -
|
|
133
|
+
#pragma mark - Event Emission
|
|
107
134
|
|
|
108
135
|
- (void)emitEvent:(NSDictionary *)dictionary {
|
|
136
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
109
137
|
[self emitOnNewEvent:dictionary];
|
|
138
|
+
#else
|
|
139
|
+
[self sendEventWithName:@"onNewEvent" body:dictionary];
|
|
140
|
+
#endif
|
|
110
141
|
}
|
|
111
142
|
|
|
112
143
|
- (void)emitVoipEvent:(NSDictionary *)dictionary {
|
|
144
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
113
145
|
[self emitOnNewVoipEvent:dictionary];
|
|
146
|
+
#else
|
|
147
|
+
[self sendEventWithName:@"onNewVoipEvent" body:dictionary];
|
|
148
|
+
#endif
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#pragma mark - Internal Helpers
|
|
152
|
+
|
|
153
|
+
- (void)_setupiOSWithOptions:(NSDictionary *)optionsDict {
|
|
154
|
+
[_moduleImpl setupWithOptions:optionsDict];
|
|
155
|
+
|
|
156
|
+
// Inject WebRTCModule so CallingxImpl can access AudioDeviceModule.
|
|
157
|
+
// self.bridge is NOT available on TurboModules — use currentBridge instead,
|
|
158
|
+
// which returns the real RCTBridge or RCTBridgeProxy (bridgeless interop).
|
|
159
|
+
WebRTCModule *webrtcModule = [[RCTBridge currentBridge] moduleForName:@"WebRTCModule"];
|
|
160
|
+
_moduleImpl.webRTCModule = webrtcModule;
|
|
161
|
+
|
|
162
|
+
self.callKeepCallController = _moduleImpl.callKeepCallController;
|
|
163
|
+
self.callKeepProvider = _moduleImpl.callKeepProvider;
|
|
114
164
|
}
|
|
115
165
|
|
|
116
|
-
#pragma mark -
|
|
166
|
+
#pragma mark - setupiOS
|
|
117
167
|
|
|
168
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
118
169
|
- (void)setupiOS:(JS::NativeCallingx::SpecSetupiOSOptions &)options {
|
|
119
170
|
NSDictionary *optionsDict = @{
|
|
120
171
|
@"supportsVideo" : @(options.supportsVideo()),
|
|
@@ -127,41 +178,106 @@
|
|
|
127
178
|
@"displayCallTimeout" : @(options.displayCallTimeout())
|
|
128
179
|
};
|
|
129
180
|
|
|
130
|
-
[
|
|
131
|
-
|
|
132
|
-
// Inject WebRTCModule so CallingxImpl can access AudioDeviceModule.
|
|
133
|
-
// self.bridge is NOT available on TurboModules — use currentBridge instead,
|
|
134
|
-
// which returns the real RCTBridge or RCTBridgeProxy (bridgeless interop).
|
|
135
|
-
WebRTCModule *webrtcModule = [[RCTBridge currentBridge] moduleForName:@"WebRTCModule"];
|
|
136
|
-
_moduleImpl.webRTCModule = webrtcModule;
|
|
137
|
-
|
|
138
|
-
self.callKeepCallController = _moduleImpl.callKeepCallController;
|
|
139
|
-
self.callKeepProvider = _moduleImpl.callKeepProvider;
|
|
181
|
+
[self _setupiOSWithOptions:optionsDict];
|
|
140
182
|
}
|
|
183
|
+
#else
|
|
184
|
+
RCT_EXPORT_METHOD(setupiOS:(NSDictionary *)options) {
|
|
185
|
+
NSDictionary *optionsDict = @{
|
|
186
|
+
@"supportsVideo" : options[@"supportsVideo"] ?: @(NO),
|
|
187
|
+
@"maximumCallsPerCallGroup" : options[@"maximumCallsPerCallGroup"] ?: @(1),
|
|
188
|
+
@"maximumCallGroups" : options[@"maximumCallGroups"] ?: @(1),
|
|
189
|
+
@"handleType" : options[@"handleType"] ?: @"generic",
|
|
190
|
+
@"ringtoneSound" : options[@"sound"] ?: @"",
|
|
191
|
+
@"imageName" : options[@"imageName"] ?: @"",
|
|
192
|
+
@"includesCallsInRecents" : options[@"callsHistory"] ?: @(NO),
|
|
193
|
+
@"displayCallTimeout" : options[@"displayCallTimeout"] ?: @(0)
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
[self _setupiOSWithOptions:optionsDict];
|
|
197
|
+
}
|
|
198
|
+
#endif
|
|
141
199
|
|
|
200
|
+
#pragma mark - setupAndroid
|
|
201
|
+
|
|
202
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
203
|
+
- (void)setupAndroid:(JS::NativeCallingx::SpecSetupAndroidOptions &)options {
|
|
204
|
+
// iOS only - leave empty
|
|
205
|
+
}
|
|
206
|
+
#else
|
|
207
|
+
RCT_EXPORT_METHOD(setupAndroid:(NSDictionary *)options) {
|
|
208
|
+
// iOS only - leave empty
|
|
209
|
+
}
|
|
210
|
+
#endif
|
|
211
|
+
|
|
212
|
+
#pragma mark - setShouldRejectCallWhenBusy
|
|
213
|
+
|
|
214
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
142
215
|
- (void)setShouldRejectCallWhenBusy:(BOOL)shouldReject {
|
|
143
216
|
[Settings setShouldRejectCallWhenBusy:shouldReject];
|
|
144
217
|
}
|
|
218
|
+
#else
|
|
219
|
+
RCT_EXPORT_METHOD(setShouldRejectCallWhenBusy:(BOOL)shouldReject) {
|
|
220
|
+
[Settings setShouldRejectCallWhenBusy:shouldReject];
|
|
221
|
+
}
|
|
222
|
+
#endif
|
|
223
|
+
|
|
224
|
+
#pragma mark - getInitialEvents
|
|
145
225
|
|
|
226
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
146
227
|
- (NSArray<NSDictionary *> *)getInitialEvents {
|
|
147
228
|
return [_moduleImpl getInitialEvents];
|
|
148
229
|
}
|
|
230
|
+
#else
|
|
231
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getInitialEvents) {
|
|
232
|
+
return [_moduleImpl getInitialEvents];
|
|
233
|
+
}
|
|
234
|
+
#endif
|
|
149
235
|
|
|
236
|
+
#pragma mark - getInitialVoipEvents
|
|
237
|
+
|
|
238
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
150
239
|
- (NSArray<NSDictionary *> *)getInitialVoipEvents {
|
|
151
240
|
return [[VoipNotificationsManager shared] getInitialEvents];
|
|
152
241
|
}
|
|
242
|
+
#else
|
|
243
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getInitialVoipEvents) {
|
|
244
|
+
return [[VoipNotificationsManager shared] getInitialEvents];
|
|
245
|
+
}
|
|
246
|
+
#endif
|
|
247
|
+
|
|
248
|
+
#pragma mark - registerVoipToken
|
|
153
249
|
|
|
250
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
154
251
|
- (void)registerVoipToken {
|
|
155
252
|
[[VoipNotificationsManager shared] registerVoipToken];
|
|
156
253
|
}
|
|
254
|
+
#else
|
|
255
|
+
RCT_EXPORT_METHOD(registerVoipToken) {
|
|
256
|
+
[[VoipNotificationsManager shared] registerVoipToken];
|
|
257
|
+
}
|
|
258
|
+
#endif
|
|
259
|
+
|
|
260
|
+
#pragma mark - answerIncomingCall
|
|
157
261
|
|
|
262
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
158
263
|
- (void)answerIncomingCall:(nonnull NSString *)callId
|
|
159
264
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
160
265
|
reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
161
266
|
BOOL result = [_moduleImpl answerIncomingCall:callId];
|
|
162
267
|
resolve(@(result));
|
|
163
268
|
}
|
|
269
|
+
#else
|
|
270
|
+
RCT_EXPORT_METHOD(answerIncomingCall:(NSString *)callId
|
|
271
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
272
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
273
|
+
BOOL result = [_moduleImpl answerIncomingCall:callId];
|
|
274
|
+
resolve(@(result));
|
|
275
|
+
}
|
|
276
|
+
#endif
|
|
277
|
+
|
|
278
|
+
#pragma mark - displayIncomingCall
|
|
164
279
|
|
|
280
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
165
281
|
- (void)displayIncomingCall:(nonnull NSString *)callId
|
|
166
282
|
phoneNumber:(nonnull NSString *)phoneNumber
|
|
167
283
|
callerName:(nonnull NSString *)callerName
|
|
@@ -177,7 +293,27 @@
|
|
|
177
293
|
reject:reject
|
|
178
294
|
];
|
|
179
295
|
}
|
|
296
|
+
#else
|
|
297
|
+
RCT_EXPORT_METHOD(displayIncomingCall:(NSString *)callId
|
|
298
|
+
phoneNumber:(NSString *)phoneNumber
|
|
299
|
+
callerName:(NSString *)callerName
|
|
300
|
+
hasVideo:(BOOL)hasVideo
|
|
301
|
+
displayOptions:(NSDictionary *)displayOptions
|
|
302
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
303
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
304
|
+
[_moduleImpl displayIncomingCallWithCallId:callId
|
|
305
|
+
phoneNumber:phoneNumber
|
|
306
|
+
callerName:callerName
|
|
307
|
+
hasVideo:hasVideo
|
|
308
|
+
resolve:resolve
|
|
309
|
+
reject:reject
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
#endif
|
|
180
313
|
|
|
314
|
+
#pragma mark - endCallWithReason
|
|
315
|
+
|
|
316
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
181
317
|
- (void)endCallWithReason:(nonnull NSString *)callId
|
|
182
318
|
reason:(double)reason
|
|
183
319
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
@@ -185,29 +321,79 @@
|
|
|
185
321
|
[CallingxImpl endCall:callId reason:(int)reason];
|
|
186
322
|
resolve(@YES);
|
|
187
323
|
}
|
|
324
|
+
#else
|
|
325
|
+
RCT_EXPORT_METHOD(endCallWithReason:(NSString *)callId
|
|
326
|
+
reason:(double)reason
|
|
327
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
328
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
329
|
+
[CallingxImpl endCall:callId reason:(int)reason];
|
|
330
|
+
resolve(@YES);
|
|
331
|
+
}
|
|
332
|
+
#endif
|
|
188
333
|
|
|
334
|
+
#pragma mark - endCall
|
|
335
|
+
|
|
336
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
189
337
|
- (void)endCall:(nonnull NSString *)callId
|
|
190
338
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
191
339
|
reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
192
340
|
BOOL result = [_moduleImpl endCall:callId];
|
|
193
341
|
resolve(@(result));
|
|
194
342
|
}
|
|
343
|
+
#else
|
|
344
|
+
RCT_EXPORT_METHOD(endCall:(NSString *)callId
|
|
345
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
346
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
347
|
+
BOOL result = [_moduleImpl endCall:callId];
|
|
348
|
+
resolve(@(result));
|
|
349
|
+
}
|
|
350
|
+
#endif
|
|
195
351
|
|
|
352
|
+
#pragma mark - isCallRegistered
|
|
353
|
+
|
|
354
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
196
355
|
- (NSNumber *)isCallTracked:(nonnull NSString *)callId {
|
|
197
356
|
return @([_moduleImpl isCallTracked:callId]);
|
|
198
357
|
}
|
|
358
|
+
#else
|
|
359
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isCallTracked:(NSString *)callId) {
|
|
360
|
+
return @([_moduleImpl isCallTracked:callId]);
|
|
361
|
+
}
|
|
362
|
+
#endif
|
|
363
|
+
|
|
364
|
+
#pragma mark - hasRegisteredCall
|
|
199
365
|
|
|
366
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
200
367
|
- (NSNumber *)hasRegisteredCall {
|
|
201
368
|
return @([CallingxImpl hasRegisteredCall]);
|
|
202
369
|
}
|
|
370
|
+
#else
|
|
371
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(hasRegisteredCall) {
|
|
372
|
+
return @([CallingxImpl hasRegisteredCall]);
|
|
373
|
+
}
|
|
374
|
+
#endif
|
|
375
|
+
|
|
376
|
+
#pragma mark - setCurrentCallActive
|
|
203
377
|
|
|
378
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
204
379
|
- (void)setCurrentCallActive:(nonnull NSString *)callId
|
|
205
380
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
206
381
|
reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
207
382
|
BOOL result = [_moduleImpl setCurrentCallActive:callId];
|
|
208
383
|
resolve(@(result));
|
|
209
384
|
}
|
|
385
|
+
#else
|
|
386
|
+
RCT_EXPORT_METHOD(setCurrentCallActive:(NSString *)callId
|
|
387
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
388
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
389
|
+
BOOL result = [_moduleImpl setCurrentCallActive:callId];
|
|
390
|
+
resolve(@(result));
|
|
391
|
+
}
|
|
392
|
+
#endif
|
|
210
393
|
|
|
394
|
+
#pragma mark - setMutedCall
|
|
395
|
+
|
|
396
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
211
397
|
- (void)setMutedCall:(nonnull NSString *)callId
|
|
212
398
|
isMuted:(BOOL)isMuted
|
|
213
399
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
@@ -215,7 +401,19 @@
|
|
|
215
401
|
BOOL result = [_moduleImpl setMutedCall:callId isMuted:isMuted];
|
|
216
402
|
resolve(@(result));
|
|
217
403
|
}
|
|
404
|
+
#else
|
|
405
|
+
RCT_EXPORT_METHOD(setMutedCall:(NSString *)callId
|
|
406
|
+
isMuted:(BOOL)isMuted
|
|
407
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
408
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
409
|
+
BOOL result = [_moduleImpl setMutedCall:callId isMuted:isMuted];
|
|
410
|
+
resolve(@(result));
|
|
411
|
+
}
|
|
412
|
+
#endif
|
|
413
|
+
|
|
414
|
+
#pragma mark - setOnHoldCall
|
|
218
415
|
|
|
416
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
219
417
|
- (void)setOnHoldCall:(nonnull NSString *)callId
|
|
220
418
|
isOnHold:(BOOL)isOnHold
|
|
221
419
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
@@ -223,7 +421,19 @@
|
|
|
223
421
|
BOOL result = [_moduleImpl setOnHoldCall:callId isOnHold:isOnHold];
|
|
224
422
|
resolve(@(result));
|
|
225
423
|
}
|
|
424
|
+
#else
|
|
425
|
+
RCT_EXPORT_METHOD(setOnHoldCall:(NSString *)callId
|
|
426
|
+
isOnHold:(BOOL)isOnHold
|
|
427
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
428
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
429
|
+
BOOL result = [_moduleImpl setOnHoldCall:callId isOnHold:isOnHold];
|
|
430
|
+
resolve(@(result));
|
|
431
|
+
}
|
|
432
|
+
#endif
|
|
433
|
+
|
|
434
|
+
#pragma mark - startCall
|
|
226
435
|
|
|
436
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
227
437
|
- (void)startCall:(nonnull NSString *)callId
|
|
228
438
|
phoneNumber:(nonnull NSString *)phoneNumber
|
|
229
439
|
callerName:(nonnull NSString *)callerName
|
|
@@ -237,7 +447,25 @@
|
|
|
237
447
|
hasVideo:hasVideo];
|
|
238
448
|
resolve(@YES);
|
|
239
449
|
}
|
|
450
|
+
#else
|
|
451
|
+
RCT_EXPORT_METHOD(startCall:(NSString *)callId
|
|
452
|
+
phoneNumber:(NSString *)phoneNumber
|
|
453
|
+
callerName:(NSString *)callerName
|
|
454
|
+
hasVideo:(BOOL)hasVideo
|
|
455
|
+
displayOptions:(NSDictionary *)displayOptions
|
|
456
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
457
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
458
|
+
[_moduleImpl startCallWithCallId:callId
|
|
459
|
+
phoneNumber:phoneNumber
|
|
460
|
+
callerName:callerName
|
|
461
|
+
hasVideo:hasVideo];
|
|
462
|
+
resolve(@YES);
|
|
463
|
+
}
|
|
464
|
+
#endif
|
|
465
|
+
|
|
466
|
+
#pragma mark - updateDisplay
|
|
240
467
|
|
|
468
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
241
469
|
- (void)updateDisplay:(nonnull NSString *)callId
|
|
242
470
|
phoneNumber:(nonnull NSString *)phoneNumber
|
|
243
471
|
callerName:(nonnull NSString *)callerName
|
|
@@ -249,15 +477,35 @@
|
|
|
249
477
|
callerName:callerName];
|
|
250
478
|
resolve(@(result));
|
|
251
479
|
}
|
|
480
|
+
#else
|
|
481
|
+
RCT_EXPORT_METHOD(updateDisplay:(NSString *)callId
|
|
482
|
+
phoneNumber:(NSString *)phoneNumber
|
|
483
|
+
callerName:(NSString *)callerName
|
|
484
|
+
displayOptions:(NSDictionary *)displayOptions
|
|
485
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
486
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
487
|
+
BOOL result = [_moduleImpl updateDisplayWithCallId:callId
|
|
488
|
+
phoneNumber:phoneNumber
|
|
489
|
+
callerName:callerName];
|
|
490
|
+
resolve(@(result));
|
|
491
|
+
}
|
|
492
|
+
#endif
|
|
493
|
+
|
|
494
|
+
#pragma mark - log
|
|
252
495
|
|
|
496
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
253
497
|
- (void)log:(NSString *)message level:(NSString *)level {
|
|
254
498
|
NSLog(@"[Callingx][log] %@, %@", message, level);
|
|
255
499
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
500
|
+
#else
|
|
501
|
+
RCT_EXPORT_METHOD(log:(NSString *)message level:(NSString *)level) {
|
|
502
|
+
NSLog(@"[Callingx][log] %@, %@", message, level);
|
|
259
503
|
}
|
|
504
|
+
#endif
|
|
505
|
+
|
|
506
|
+
#pragma mark - startBackgroundTask
|
|
260
507
|
|
|
508
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
261
509
|
- (void)startBackgroundTask:(NSString *)taskName
|
|
262
510
|
timeout:(double)timeout
|
|
263
511
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
@@ -265,26 +513,72 @@
|
|
|
265
513
|
// Not implemented on iOS
|
|
266
514
|
resolve(@YES);
|
|
267
515
|
}
|
|
516
|
+
#else
|
|
517
|
+
RCT_EXPORT_METHOD(startBackgroundTask:(NSString *)taskName
|
|
518
|
+
timeout:(double)timeout
|
|
519
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
520
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
521
|
+
// Not implemented on iOS
|
|
522
|
+
resolve(@YES);
|
|
523
|
+
}
|
|
524
|
+
#endif
|
|
525
|
+
|
|
526
|
+
#pragma mark - stopBackgroundTask
|
|
268
527
|
|
|
528
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
269
529
|
- (void)stopBackgroundTask:(NSString *)taskName
|
|
270
530
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
271
531
|
reject:(RCTPromiseRejectBlock)reject {
|
|
272
532
|
// Not implemented on iOS
|
|
273
533
|
resolve(@YES);
|
|
274
534
|
}
|
|
535
|
+
#else
|
|
536
|
+
RCT_EXPORT_METHOD(stopBackgroundTask:(NSString *)taskName
|
|
537
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
538
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
539
|
+
// Not implemented on iOS
|
|
540
|
+
resolve(@YES);
|
|
541
|
+
}
|
|
542
|
+
#endif
|
|
543
|
+
|
|
544
|
+
#pragma mark - registerBackgroundTaskAvailable
|
|
275
545
|
|
|
546
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
276
547
|
- (void)registerBackgroundTaskAvailable {
|
|
277
548
|
// Not implemented on iOS - background tasks work differently on iOS
|
|
278
549
|
}
|
|
550
|
+
#else
|
|
551
|
+
RCT_EXPORT_METHOD(registerBackgroundTaskAvailable) {
|
|
552
|
+
// Not implemented on iOS - background tasks work differently on iOS
|
|
553
|
+
}
|
|
554
|
+
#endif
|
|
555
|
+
|
|
556
|
+
#pragma mark - isServiceStarted
|
|
279
557
|
|
|
558
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
280
559
|
- (void)isServiceStarted:(RCTPromiseResolveBlock)resolve
|
|
281
560
|
reject:(RCTPromiseRejectBlock)reject {
|
|
282
561
|
// iOS doesn't use a service like Android, always return true
|
|
283
562
|
resolve(@YES);
|
|
284
563
|
}
|
|
564
|
+
#else
|
|
565
|
+
RCT_EXPORT_METHOD(isServiceStarted:(RCTPromiseResolveBlock)resolve
|
|
566
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
567
|
+
// iOS doesn't use a service like Android, always return true
|
|
568
|
+
resolve(@YES);
|
|
569
|
+
}
|
|
570
|
+
#endif
|
|
571
|
+
|
|
572
|
+
#pragma mark - canPostNotifications
|
|
285
573
|
|
|
574
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
286
575
|
- (nonnull NSNumber *)canPostNotifications {
|
|
287
576
|
return @YES;
|
|
288
577
|
}
|
|
578
|
+
#else
|
|
579
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(canPostNotifications) {
|
|
580
|
+
return @YES;
|
|
581
|
+
}
|
|
582
|
+
#endif
|
|
289
583
|
|
|
290
584
|
@end
|
package/package.json
CHANGED
package/src/EventManager.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { NativeEventEmitter, type EventSubscription } from 'react-native';
|
|
2
2
|
import NativeCallingModule from './spec/NativeCallingx';
|
|
3
3
|
import type {
|
|
4
4
|
EventData,
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
VoipEventData,
|
|
7
7
|
VoipEventName,
|
|
8
8
|
} from './types';
|
|
9
|
-
import { isVoipEvent } from './utils/utils';
|
|
9
|
+
import { isVoipEvent, isTurboModuleEnabled } from './utils/utils';
|
|
10
10
|
|
|
11
11
|
type EventListener<T> = (params: T) => void;
|
|
12
12
|
|
|
@@ -31,10 +31,23 @@ class EventManager<Name extends EventName | VoipEventName, Params> {
|
|
|
31
31
|
eventListeners.forEach((listener) => listener(event.params as Params));
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
if (
|
|
35
|
-
|
|
34
|
+
if (isTurboModuleEnabled) {
|
|
35
|
+
if (isVoipEvent(eventName)) {
|
|
36
|
+
this.subscription = NativeCallingModule.onNewVoipEvent(eventHandler);
|
|
37
|
+
} else {
|
|
38
|
+
this.subscription = NativeCallingModule.onNewEvent(eventHandler);
|
|
39
|
+
}
|
|
36
40
|
} else {
|
|
37
|
-
|
|
41
|
+
const nativeEmitter = new NativeEventEmitter(
|
|
42
|
+
NativeCallingModule as any,
|
|
43
|
+
);
|
|
44
|
+
const nativeEventName = isVoipEvent(eventName)
|
|
45
|
+
? 'onNewVoipEvent'
|
|
46
|
+
: 'onNewEvent';
|
|
47
|
+
this.subscription = nativeEmitter.addListener(
|
|
48
|
+
nativeEventName,
|
|
49
|
+
eventHandler as any,
|
|
50
|
+
);
|
|
38
51
|
}
|
|
39
52
|
}
|
|
40
53
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
TurboModuleRegistry,
|
|
3
|
+
NativeModules,
|
|
4
|
+
type TurboModule,
|
|
5
|
+
} from 'react-native';
|
|
2
6
|
|
|
3
7
|
// @ts-expect-error - CodegenTypes is not properly typed
|
|
4
8
|
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
9
|
+
import { isTurboModuleEnabled } from '../utils/utils';
|
|
5
10
|
|
|
6
11
|
export interface Spec extends TurboModule {
|
|
7
12
|
setupiOS(options: {
|
|
@@ -173,4 +178,8 @@ export interface Spec extends TurboModule {
|
|
|
173
178
|
log(message: string, level: 'debug' | 'info' | 'warn' | 'error'): void;
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
const CallingxModule: Spec = isTurboModuleEnabled
|
|
182
|
+
? TurboModuleRegistry.getEnforcing<Spec>('Callingx')
|
|
183
|
+
: (NativeModules.Callingx as Spec);
|
|
184
|
+
|
|
185
|
+
export default CallingxModule;
|
package/src/utils/utils.ts
CHANGED
|
File without changes
|