omikit-plugin 3.2.73 → 3.2.75
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/README.md +4 -2
- package/ios/CallProcess/CallManager.swift +30 -32
- package/ios/CallProcess/OmiUtils.swift +20 -0
- package/omikit-plugin.podspec +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -765,11 +765,13 @@ const result = await startCall({
|
|
|
765
765
|
| `"COULD_NOT_FIND_END_POINT"` | 5 | Please login before making your call |
|
|
766
766
|
| `"REGISTER_ACCOUNT_FAIL"` | 6 | Can't log in to OMI (maybe wrong login information) |
|
|
767
767
|
| `"START_CALL_FAIL"` | 7 | Call failed, please try again |
|
|
768
|
-
| `"HAVE_ANOTHER_CALL"` | 9 | There is another call in progress; please wait for that call to end
|
|
768
|
+
| `"HAVE_ANOTHER_CALL"` | 9 | There is another call in progress; please wait for that call to end |
|
|
769
|
+
| `"EXTENSION_NUMBER_IS_OFF"` | 10 | Extension number off User is turn Off |
|
|
769
770
|
| `"START_CALL_SUCCESS"` | 8 | START CALL SUCCESSFULLY |
|
|
770
771
|
|
|
771
772
|
<br>
|
|
772
773
|
|
|
774
|
+
|
|
773
775
|
📌 **startCallWithUuid()**
|
|
774
776
|
|
|
775
777
|
✅ Description: Call with UUID (only support with Api key):
|
|
@@ -1089,7 +1091,7 @@ const result = await startCallWithUuid({
|
|
|
1089
1091
|
import { omiEmitter } from 'omikit-plugin';
|
|
1090
1092
|
|
|
1091
1093
|
/*
|
|
1092
|
-
❌ ❌ With TypeScript, in
|
|
1094
|
+
❌ ❌ With TypeScript, in Android, it seems our omiEmitter is not working properly. Please use the following manual declaration, to ensure performance
|
|
1093
1095
|
*/
|
|
1094
1096
|
|
|
1095
1097
|
// 📌 For TypeScript, Android
|
|
@@ -384,41 +384,38 @@ class CallManager {
|
|
|
384
384
|
|
|
385
385
|
|
|
386
386
|
/// Start call
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
func startCall(_ phoneNumber: String, isVideo: Bool, completion: @escaping (_: String) -> Void) {
|
|
388
|
+
let secondsSinceCurrentTime = lastTimeCall.timeIntervalSinceNow
|
|
389
|
+
guestPhone = phoneNumber
|
|
390
|
+
var isCompletionCalled = false // ✅ Biến kiểm soát callback để tránh gọi nhiều lần
|
|
391
391
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if !completionCalled {
|
|
396
|
-
completion("{\"status\": \"6\", \"message\": \"REGISTER_ACCOUNT_FAIL\"}")
|
|
397
|
-
completionCalled = true
|
|
398
|
-
}
|
|
399
|
-
return
|
|
400
|
-
}
|
|
392
|
+
OmiClient.startCall(phoneNumber, isVideo: isVideo) { status in
|
|
393
|
+
DispatchQueue.main.async {
|
|
394
|
+
if isCompletionCalled { return } // ✅ Nếu callback đã gọi trước đó thì không thực hiện tiếp
|
|
401
395
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
396
|
+
var dataToSend: [String: Any] = [
|
|
397
|
+
"status": status.rawValue,
|
|
398
|
+
"_id": "",
|
|
399
|
+
"message": OmiUtils.messageCall(type: status.rawValue),
|
|
400
|
+
"message_detail": OmiUtils.messageCallDetail(type: statusCall.rawValue)
|
|
401
|
+
]
|
|
407
402
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
403
|
+
// ✅ Kiểm tra và lấy ID cuộc gọi nếu có
|
|
404
|
+
if let callCurrent = self.omiLib.getCurrentCall() {
|
|
405
|
+
dataToSend["_id"] = String(describing: OmiCallModel(omiCall: callCurrent).uuid)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ✅ Chuyển đổi Dictionary sang JSON
|
|
409
|
+
if let jsonString = OmiUtils.convertDictionaryToJson(dictionary: dataToSend) {
|
|
410
|
+
completion(jsonString)
|
|
411
|
+
} else {
|
|
412
|
+
completion("{\"status\": \"error\", \"message\": \"JSON conversion failed\"}")
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
isCompletionCalled = true // ✅ Đánh dấu callback đã được gọi
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
422
419
|
|
|
423
420
|
|
|
424
421
|
/// Start call
|
|
@@ -433,6 +430,7 @@ class CallManager {
|
|
|
433
430
|
"status": statusCall.rawValue,
|
|
434
431
|
"_id": "",
|
|
435
432
|
"message": OmiUtils.messageCall(type: statusCall.rawValue)
|
|
433
|
+
"message_detail": OmiUtils.messageCallDetail(type: statusCall.rawValue)
|
|
436
434
|
]
|
|
437
435
|
if(callCurrent != nil){
|
|
438
436
|
dataToSend["_id"] = String(describing: OmiCallModel(omiCall: callCurrent!).uuid)
|
|
@@ -35,6 +35,8 @@ public class OmiUtils {
|
|
|
35
35
|
return "START_CALL_FAIL"
|
|
36
36
|
case 9:
|
|
37
37
|
return "HAVE_ANOTHER_CALL"
|
|
38
|
+
case 10:
|
|
39
|
+
return "EXTENSION_NUMBER_IS_OFF"
|
|
38
40
|
default:
|
|
39
41
|
return "START_CALL_SUCCESS"
|
|
40
42
|
}
|
|
@@ -64,10 +66,28 @@ public class OmiUtils {
|
|
|
64
66
|
case 6: return "REGISTER_ACCOUNT_FAIL"
|
|
65
67
|
case 7: return "START_CALL_FAIL"
|
|
66
68
|
case 9: return "HAVE_ANOTHER_CALL"
|
|
69
|
+
case 10: return "EXTENSION_NUMBER_IS_OFF"
|
|
67
70
|
default: return "START_CALL_SUCCESS"
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
/// trả về mã lỗi chi tiết
|
|
75
|
+
static func messageCallDetail(type: Int) -> String {
|
|
76
|
+
switch type {
|
|
77
|
+
case 0: return "UUID đang trống hoặc không chính xác"
|
|
78
|
+
case 1: return "SIP_USER đang trống hoặc không chính xác"
|
|
79
|
+
case 2: return "Bạn đang gọi chính mình"
|
|
80
|
+
case 3: return "Vượt quá số lần gọi, vui lòng thử lại sau 2s"
|
|
81
|
+
case 4: return "Bạn chưa cấp quyền"
|
|
82
|
+
case 5: return "Vui lòng log in vào OMI"
|
|
83
|
+
case 6: return "Đăng nhập vào OMI thất bại, thông tin đăng nhập không chính xác"
|
|
84
|
+
case 7: return "Khởi tạo cuộc gọi không thành công"
|
|
85
|
+
case 9: return "Có một cuộc gọi khác chưa kết thúc"
|
|
86
|
+
case 10: return "Số nội bộ đã tắt"
|
|
87
|
+
default: return "Khởi tạo cuộc gọi thành công"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
71
91
|
static func checkTypeNumber(phoneNumber: String) -> String {
|
|
72
92
|
var result = "phone"
|
|
73
93
|
|
package/omikit-plugin.podspec
CHANGED