edoctor-sendbird-calls 1.0.0 → 1.0.1-beta.10
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/CXCallManager.swift
CHANGED
|
@@ -194,7 +194,7 @@ extension CXCallManager: CXProviderDelegate {
|
|
|
194
194
|
extension DirectCallEndResult {
|
|
195
195
|
var asCXCallEndedReason: CXCallEndedReason? {
|
|
196
196
|
switch self {
|
|
197
|
-
case .connectionLost, .timedOut, .acceptFailed, .dialFailed, .unknown:
|
|
197
|
+
case .connectionLost, .timedOut, .acceptFailed, .dialFailed, .notConnected, .unknown:
|
|
198
198
|
return .failed
|
|
199
199
|
case .completed, .canceled:
|
|
200
200
|
return .remoteEnded
|
package/ios/CXProvider.swift
CHANGED
|
@@ -11,7 +11,12 @@ import UIKit
|
|
|
11
11
|
extension CXProviderConfiguration {
|
|
12
12
|
// The app's provider configuration, representing its CallKit capabilities
|
|
13
13
|
static var `default`: CXProviderConfiguration {
|
|
14
|
-
let providerConfiguration
|
|
14
|
+
let providerConfiguration: CXProviderConfiguration
|
|
15
|
+
if #available(iOS 14.0, *) {
|
|
16
|
+
providerConfiguration = CXProviderConfiguration()
|
|
17
|
+
} else {
|
|
18
|
+
providerConfiguration = CXProviderConfiguration(localizedName: "eDoctor")
|
|
19
|
+
}
|
|
15
20
|
if let image = UIImage(named: "icLogoSymbolInverse") {
|
|
16
21
|
providerConfiguration.iconTemplateImageData = image.pngData()
|
|
17
22
|
}
|
|
@@ -43,25 +43,15 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
private func setupSendBird() {
|
|
46
|
-
|
|
46
|
+
_ = UserDefaults(suiteName: "edoctorStorage")
|
|
47
47
|
let appId = "0BEF9C57-BA3B-474E-A40F-62B027AA47F6"
|
|
48
48
|
|
|
49
49
|
let config = SendBirdCall.configure(appId: appId)
|
|
50
|
-
if(config){
|
|
51
|
-
print(TAG + "CONFIG SUCCESS")
|
|
52
|
-
}else {
|
|
53
|
-
print(TAG + "CONFIG FAILED")
|
|
54
|
-
}
|
|
55
50
|
SendBirdCall.addDelegate(self, identifier: "RNSendBirdCalls")
|
|
56
51
|
SendBirdCall.setDirectCallDialingSoundOnWhenSilentMode(isEnabled: true)
|
|
57
52
|
SendBirdCall.addRecordingDelegate(self, identifier: "RNSendBirdRecording")
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
// MARK: - RCTEventEmitter overrides for RN 0.79.x
|
|
61
|
-
override static func requiresMainQueueSetup() -> Bool {
|
|
62
|
-
return true
|
|
63
|
-
}
|
|
64
|
-
|
|
65
55
|
override func supportedEvents() -> [String]! {
|
|
66
56
|
return [
|
|
67
57
|
RNSendBirdCalls.onEnded,
|
|
@@ -130,6 +120,8 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
130
120
|
return
|
|
131
121
|
}
|
|
132
122
|
|
|
123
|
+
print(self.TAG + "AUTHENTICATE SUCCESS \(user.userId)")
|
|
124
|
+
|
|
133
125
|
resolve(["succeeded": true ,"userId": user.userId, "nickname": user.nickname ?? ""])
|
|
134
126
|
}
|
|
135
127
|
}
|
|
@@ -137,9 +129,9 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
137
129
|
@objc func deAuthenticate(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
138
130
|
SendBirdCall.unregisterAllVoIPPushTokens { error in
|
|
139
131
|
guard error == nil else {
|
|
140
|
-
print(
|
|
132
|
+
print(self.TAG + "error deauthen")
|
|
141
133
|
let message = error?.localizedDescription ?? "Có lỗi xảy ra"
|
|
142
|
-
print(
|
|
134
|
+
print(self.TAG + message)
|
|
143
135
|
return
|
|
144
136
|
}
|
|
145
137
|
}
|
|
@@ -151,15 +143,16 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
151
143
|
return
|
|
152
144
|
}
|
|
153
145
|
|
|
146
|
+
print(self.TAG + "DEAUTHENTICATE SUCCESS")
|
|
154
147
|
resolve(["succeeded": true ])
|
|
155
148
|
}
|
|
156
149
|
}
|
|
157
150
|
|
|
158
151
|
@objc func initSendBird(_ appId: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
159
152
|
let config = SendBirdCall.configure(appId: appId)
|
|
160
|
-
if(config){
|
|
153
|
+
if (config != nil) {
|
|
161
154
|
resolve(["succeeded": true ])
|
|
162
|
-
}else {
|
|
155
|
+
} else {
|
|
163
156
|
resolve(["succeeded": false ])
|
|
164
157
|
}
|
|
165
158
|
}
|
|
@@ -181,6 +174,7 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
181
174
|
return
|
|
182
175
|
}
|
|
183
176
|
|
|
177
|
+
print(self.TAG + "DIAL SUCCESS")
|
|
184
178
|
resolve(["succeeded": true ,"callId": call.callId, "caller": call.caller?.userId ?? "", "callee": call.callee?.userId ?? ""])
|
|
185
179
|
}
|
|
186
180
|
CALL_ACTIVE = directCall;
|
|
@@ -197,6 +191,7 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
197
191
|
CXCallManager.shared.endCXCall(call)
|
|
198
192
|
let params = getParamFromDirectCall(call: call)
|
|
199
193
|
params.setValue(true, forKey: "succeeded")
|
|
194
|
+
print(TAG + "END CALL SUCCESS")
|
|
200
195
|
resolve(params)
|
|
201
196
|
}
|
|
202
197
|
|
|
@@ -211,6 +206,7 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
211
206
|
call.accept(with: acceptParams)
|
|
212
207
|
let params = getParamFromDirectCall(call: call)
|
|
213
208
|
params.setValue(true, forKey: "succeeded")
|
|
209
|
+
print(TAG + "ACCEPT CALL SUCCESS")
|
|
214
210
|
resolve(params)
|
|
215
211
|
}
|
|
216
212
|
|
|
@@ -245,54 +241,55 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
245
241
|
resultData.append(getParamFromDirectCall(call: directCall))
|
|
246
242
|
})
|
|
247
243
|
}
|
|
244
|
+
print(TAG + "getOngoingCalls SUCCESS")
|
|
248
245
|
resolve(resultData)
|
|
249
246
|
}
|
|
250
247
|
|
|
251
248
|
@objc func muteMicrophone(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
252
249
|
print(TAG + "muteMicrophone")
|
|
253
|
-
if(CALL_ACTIVE != nil){
|
|
250
|
+
if (CALL_ACTIVE != nil) {
|
|
254
251
|
CALL_ACTIVE?.muteMicrophone()
|
|
255
252
|
resolve(["succeeded": true])
|
|
256
|
-
}else {
|
|
253
|
+
} else {
|
|
257
254
|
resolve(["succeeded": false , "errorMessage": "Cuộc gọi không tồn tại"])
|
|
258
255
|
}
|
|
259
256
|
}
|
|
260
257
|
|
|
261
258
|
@objc func unmuteMicrophone(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
262
259
|
print(TAG + "unmuteMicrophone")
|
|
263
|
-
if(CALL_ACTIVE != nil){
|
|
260
|
+
if (CALL_ACTIVE != nil) {
|
|
264
261
|
CALL_ACTIVE?.unmuteMicrophone()
|
|
265
262
|
resolve(["succeeded": true])
|
|
266
|
-
}else {
|
|
263
|
+
} else {
|
|
267
264
|
resolve(["succeeded": false , "errorMessage": "Cuộc gọi không tồn tại"])
|
|
268
265
|
}
|
|
269
266
|
}
|
|
270
267
|
|
|
271
268
|
@objc func startVideo(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
272
269
|
print(TAG + "startVideo")
|
|
273
|
-
if(CALL_ACTIVE != nil){
|
|
270
|
+
if (CALL_ACTIVE != nil) {
|
|
274
271
|
CALL_ACTIVE?.startVideo()
|
|
275
272
|
resolve(["succeeded": true])
|
|
276
|
-
}else {
|
|
273
|
+
} else {
|
|
277
274
|
resolve(["succeeded": false , "errorMessage": "Cuộc gọi không tồn tại"])
|
|
278
275
|
}
|
|
279
276
|
}
|
|
280
277
|
|
|
281
278
|
@objc func stopVideo(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
282
279
|
print(TAG + "stopVideo")
|
|
283
|
-
if(CALL_ACTIVE != nil){
|
|
280
|
+
if (CALL_ACTIVE != nil) {
|
|
284
281
|
CALL_ACTIVE?.stopVideo()
|
|
285
282
|
resolve(["succeeded": true])
|
|
286
|
-
}else {
|
|
283
|
+
} else {
|
|
287
284
|
resolve(["succeeded": false , "errorMessage": "Cuộc gọi không tồn tại"])
|
|
288
285
|
}
|
|
289
286
|
}
|
|
290
287
|
|
|
291
288
|
@objc func switchCamera(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
292
289
|
print(TAG + "switchCamera")
|
|
293
|
-
if(CALL_ACTIVE != nil){
|
|
290
|
+
if (CALL_ACTIVE != nil) {
|
|
294
291
|
CALL_ACTIVE?.switchCamera { error in
|
|
295
|
-
if(error != nil){
|
|
292
|
+
if (error != nil) {
|
|
296
293
|
let code = "\(error?.errorCode.rawValue ?? 0)"
|
|
297
294
|
let message = error?.localizedDescription ?? "Có lỗi xảy ra"
|
|
298
295
|
resolve(["succeeded": false , "errorCode": code, "errorMessage": message])
|
|
@@ -313,9 +310,9 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
313
310
|
|
|
314
311
|
let options = isRemote ? RecordingOptions(recordingType: .localAudioRemoteAudioAndVideo, directoryPath: documentsDirectory, fileName: fileName) : RecordingOptions(recordingType: .localAudioAndVideoRemoteAudio, directoryPath: documentsDirectory, fileName: fileName)
|
|
315
312
|
|
|
316
|
-
if(CALL_ACTIVE != nil){
|
|
313
|
+
if (CALL_ACTIVE != nil) {
|
|
317
314
|
CALL_ACTIVE?.startRecording(options: options) { (recordingId, error) in
|
|
318
|
-
if(error == nil){
|
|
315
|
+
if (error == nil) {
|
|
319
316
|
let result: NSDictionary = [
|
|
320
317
|
"succeeded": true,
|
|
321
318
|
"recordingId": recordingId ?? "",
|
|
@@ -340,7 +337,7 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
340
337
|
|
|
341
338
|
@objc func stopRecording(_ recordingId: String, isVideoCall: Bool, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock){
|
|
342
339
|
print(TAG + "stopRecording")
|
|
343
|
-
if(CALL_ACTIVE != nil){
|
|
340
|
+
if (CALL_ACTIVE != nil) {
|
|
344
341
|
let resultStop: Bool = ((CALL_ACTIVE?.stopRecording(recordingId: recordingId)) != nil)
|
|
345
342
|
let result: NSDictionary = [
|
|
346
343
|
"succeeded": resultStop,
|
|
@@ -356,7 +353,7 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
356
353
|
|
|
357
354
|
@objc func endAllCalls(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
358
355
|
let ongoingCalls = SendBirdCall.getOngoingCalls()
|
|
359
|
-
if(ongoingCalls.count > 0){
|
|
356
|
+
if (ongoingCalls.count > 0) {
|
|
360
357
|
ongoingCalls.forEach({ directCall in
|
|
361
358
|
directCall.end()
|
|
362
359
|
CXCallManager.shared.endCXCall(directCall)
|
|
@@ -367,7 +364,7 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
367
364
|
|
|
368
365
|
func endCalls() {
|
|
369
366
|
let ongoingCalls = SendBirdCall.getOngoingCalls()
|
|
370
|
-
if(ongoingCalls.count > 0){
|
|
367
|
+
if (ongoingCalls.count > 0) {
|
|
371
368
|
ongoingCalls.forEach({ directCall in
|
|
372
369
|
directCall.end()
|
|
373
370
|
CXCallManager.shared.endCXCall(directCall)
|
|
@@ -389,8 +386,8 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
389
386
|
|
|
390
387
|
@available(iOS 10.0, *)
|
|
391
388
|
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
|
|
392
|
-
print(TAG + "pushRegistry
|
|
393
|
-
SendBirdCall.addDelegate(self, identifier: "RNSendBirdCalls")
|
|
389
|
+
print(TAG + "pushRegistry incoming call")
|
|
390
|
+
// SendBirdCall.addDelegate(self, identifier: "RNSendBirdCalls")
|
|
394
391
|
SendBirdCall.pushRegistry(registry, didReceiveIncomingPushWith: payload, for: type) { uuid in
|
|
395
392
|
guard uuid != nil else {
|
|
396
393
|
let update = CXCallUpdate()
|
|
@@ -429,9 +426,10 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
429
426
|
let isLocalVideoEnabled = call.isLocalVideoEnabled
|
|
430
427
|
let isLocalAudioEnabled = call.isLocalAudioEnabled
|
|
431
428
|
let customItems = call.customItems
|
|
429
|
+
let endResult = call.endResult
|
|
432
430
|
|
|
433
431
|
let params: NSMutableDictionary = [
|
|
434
|
-
"callId" : callId
|
|
432
|
+
"callId" : callId,
|
|
435
433
|
"duration": duration,
|
|
436
434
|
"isRemoteAudioEnabled": isRemoteAudioEnabled,
|
|
437
435
|
"isRemoteVideoEnabled": isRemoteVideoEnabled,
|
|
@@ -440,7 +438,8 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
440
438
|
"isVideoCall": isVideoCall,
|
|
441
439
|
"callee" : calleeMap,
|
|
442
440
|
"caller" : callerMap,
|
|
443
|
-
"customItems": customItems
|
|
441
|
+
"customItems": customItems,
|
|
442
|
+
"endResult": endResult,
|
|
444
443
|
]
|
|
445
444
|
return params
|
|
446
445
|
}
|
|
@@ -469,6 +468,8 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
469
468
|
update.hasVideo = directCall.isVideoCall
|
|
470
469
|
update.localizedCallerName = "BS. \(directCall.caller?.nickname ?? "Chưa xác định")"
|
|
471
470
|
|
|
471
|
+
print(TAG + "call count: \(SendBirdCall.getOngoingCallCount())")
|
|
472
|
+
|
|
472
473
|
if SendBirdCall.getOngoingCallCount() > 1 {
|
|
473
474
|
CXCallManager.shared.reportIncomingCall(with: uuid, update: update) { _ in
|
|
474
475
|
CXCallManager.shared.endCall(for: uuid, endedAt: Date(), reason: .declined)
|
|
@@ -525,9 +526,10 @@ class RNSendBirdCalls: RCTEventEmitter, SendBirdCallDelegate, DirectCallDelegate
|
|
|
525
526
|
print(TAG + "didEnd")
|
|
526
527
|
CALL_ACTIVE = nil
|
|
527
528
|
let params = getParamFromDirectCall(call: directCall)
|
|
529
|
+
print(self.TAG + "didEnd endResult: \(directCall.endResult.rawValue)")
|
|
528
530
|
sendEventWithName(eventName: RNSendBirdCalls.onEnded, params: params)
|
|
529
531
|
CXCallManager.shared.endCall(for: callId, endedAt: Date(), reason: directCall.endResult)
|
|
530
|
-
guard
|
|
532
|
+
guard directCall.callLog != nil else { return }
|
|
531
533
|
}
|
|
532
534
|
|
|
533
535
|
// MARK: - SendBirdRecordingDelegate
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#import "React/RCTViewManager.h"
|
|
2
2
|
@interface RCT_EXTERN_MODULE(RNVSendBirdCallsVideoManager, RCTViewManager)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
RCT_EXPORT_VIEW_PROPERTY(callId, NSString)
|
|
4
|
+
RCT_EXPORT_VIEW_PROPERTY(local, BOOL)
|
|
5
|
+
RCT_EXPORT_VIEW_PROPERTY(scaleFit, BOOL)
|
|
6
|
+
|
|
7
|
+
+ (BOOL)requiresMainQueueSetup
|
|
8
|
+
{
|
|
9
|
+
return YES;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
@end
|
|
@@ -2,14 +2,8 @@ import SendBirdCalls
|
|
|
2
2
|
|
|
3
3
|
@objc(RNVSendBirdCallsVideoManager)
|
|
4
4
|
class RNVSendBirdCallsVideoManager: RCTViewManager {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return true
|
|
5
|
+
override func view() -> UIView! {
|
|
6
|
+
return RNVSendBirdCallsVideo()
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
override func view() -> UIView! {
|
|
11
|
-
return RNVSendBirdCallsVideo()
|
|
12
|
-
|
|
13
|
-
}
|
|
14
8
|
}
|
|
15
9
|
|