omikit-plugin 3.3.14 → 3.3.15
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.
|
@@ -762,15 +762,14 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
762
762
|
fun initCallWithApiKey(data: ReadableMap, promise: Promise) {
|
|
763
763
|
mainScope.launch {
|
|
764
764
|
var loginResult = false
|
|
765
|
-
val usrName = data.getString("fullName")
|
|
766
|
-
val usrUuid = data.getString("usrUuid")
|
|
767
|
-
val apiKey = data.getString("apiKey")
|
|
765
|
+
val usrName = data.getString("fullName") ?: ""
|
|
766
|
+
val usrUuid = data.getString("usrUuid") ?: ""
|
|
767
|
+
val apiKey = data.getString("apiKey") ?: ""
|
|
768
768
|
val isVideo = data.getBoolean("isVideo") ?: false
|
|
769
769
|
val phone = data.getString("phone")
|
|
770
|
-
val firebaseToken = data.getString("fcmToken")
|
|
770
|
+
val firebaseToken = data.getString("fcmToken") ?: ""
|
|
771
771
|
val projectId = data.getString("projectId") ?: ""
|
|
772
772
|
|
|
773
|
-
requestPermission(isVideo)
|
|
774
773
|
withContext(Dispatchers.Default) {
|
|
775
774
|
try {
|
|
776
775
|
// Validate required parameters
|
|
@@ -794,10 +793,11 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
794
793
|
loginResult = OmiClient.registerWithApiKey(
|
|
795
794
|
apiKey ?: "",
|
|
796
795
|
usrName ?: "",
|
|
797
|
-
phone ?: "",
|
|
798
796
|
usrUuid ?: "",
|
|
797
|
+
phone ?: "",
|
|
799
798
|
isVideo,
|
|
800
|
-
firebaseToken
|
|
799
|
+
firebaseToken,
|
|
800
|
+
projectId
|
|
801
801
|
)
|
|
802
802
|
|
|
803
803
|
if (loginResult) {
|
|
@@ -920,61 +920,22 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
920
920
|
reactApplicationContext!!,
|
|
921
921
|
Manifest.permission.RECORD_AUDIO
|
|
922
922
|
)
|
|
923
|
+
Log.d("OMISDK", "📤 Start Call With UUID")
|
|
923
924
|
val map: WritableMap = WritableNativeMap()
|
|
924
|
-
|
|
925
|
-
// Check if we can start a new call first
|
|
926
|
-
if (!canStartNewCall()) {
|
|
927
|
-
map.putInt("status", 8) // HAVE_ANOTHER_CALL
|
|
928
|
-
map.putString("_id", "")
|
|
929
|
-
map.putString("message", messageCall(8) as String)
|
|
930
|
-
promise.resolve(map)
|
|
931
|
-
return
|
|
932
|
-
}
|
|
933
|
-
|
|
934
925
|
if (audio == PackageManager.PERMISSION_GRANTED) {
|
|
935
926
|
mainScope.launch {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
// Check if OmiClient instance and service are ready before making call
|
|
945
|
-
val omiClient = OmiClient.getInstance(reactApplicationContext!!)
|
|
946
|
-
if (omiClient == null) {
|
|
947
|
-
callResult = null
|
|
948
|
-
markCallEnded() // Clean up state
|
|
949
|
-
} else {
|
|
950
|
-
// Add small delay to ensure service is fully initialized
|
|
951
|
-
kotlinx.coroutines.delay(200) // Increased delay for better stability
|
|
952
|
-
|
|
953
|
-
// Call on main thread to avoid PJSIP thread registration issues
|
|
954
|
-
callResult = omiClient.startCallWithUuid(uuid = uuid, isVideo = isVideo)
|
|
955
|
-
|
|
956
|
-
// If call failed, mark as ended
|
|
957
|
-
if (callResult == null || callResult.ordinal <= 7) { // 0-7 are failure statuses
|
|
958
|
-
markCallEnded()
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
} catch (e: IllegalStateException) {
|
|
962
|
-
// Handle service not ready state
|
|
963
|
-
callResult = null
|
|
964
|
-
markCallEnded()
|
|
965
|
-
} catch (e: NullPointerException) {
|
|
966
|
-
// Handle null pointer exceptions
|
|
967
|
-
callResult = null
|
|
968
|
-
markCallEnded()
|
|
969
|
-
} catch (e: Throwable) {
|
|
970
|
-
// Handle any other exceptions including PJSIP thread issues
|
|
971
|
-
callResult = null
|
|
972
|
-
markCallEnded()
|
|
927
|
+
val uuid = data.getString("usrUuid") ?: ""
|
|
928
|
+
val isVideo = data.getBoolean("isVideo") ?: false;
|
|
929
|
+
|
|
930
|
+
val startCallResult =
|
|
931
|
+
OmiClient.getInstance(reactApplicationContext!!).startCallWithUuid(uuid, isVideo)
|
|
932
|
+
var statusCalltemp = startCallResult.value as Int;
|
|
933
|
+
if (startCallResult.value == 200 || startCallResult.value == 407) {
|
|
934
|
+
statusCalltemp = 8
|
|
973
935
|
}
|
|
974
|
-
var statusCalltemp = callResult?.ordinal ?: 8
|
|
975
936
|
map.putInt("status", statusCalltemp)
|
|
976
937
|
map.putString("_id", "")
|
|
977
|
-
map.putString("message", messageCall(
|
|
938
|
+
map.putString("message", messageCall(startCallResult.value) as String)
|
|
978
939
|
promise.resolve(map)
|
|
979
940
|
}
|
|
980
941
|
} else {
|
|
@@ -985,6 +946,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
985
946
|
}
|
|
986
947
|
}
|
|
987
948
|
|
|
949
|
+
|
|
988
950
|
@ReactMethod
|
|
989
951
|
fun joinCall(promise: Promise) {
|
|
990
952
|
val appContext = reactApplicationContext.applicationContext
|
|
@@ -490,13 +490,26 @@ func startCall(_ phoneNumber: String, isVideo: Bool, completion: @escaping (_: S
|
|
|
490
490
|
if let jsonString = OmiUtils.convertDictionaryToJson(dictionary: dataToSend) {
|
|
491
491
|
completion(jsonString)
|
|
492
492
|
} else {
|
|
493
|
-
|
|
493
|
+
completion("{\"status\": \"error\", \"message\": \"JSON conversion failed\"}")
|
|
494
494
|
}
|
|
495
495
|
return
|
|
496
496
|
|
|
497
497
|
}
|
|
498
498
|
|
|
499
499
|
return
|
|
500
|
+
} else {
|
|
501
|
+
var dataToSend: [String: Any] = [
|
|
502
|
+
"status": 0,
|
|
503
|
+
"_id": "",
|
|
504
|
+
"message": "INVALID_UUID",
|
|
505
|
+
"message_detail": "UUID does not exist"
|
|
506
|
+
]
|
|
507
|
+
if let jsonString = OmiUtils.convertDictionaryToJson(dictionary: dataToSend) {
|
|
508
|
+
completion(jsonString)
|
|
509
|
+
} else {
|
|
510
|
+
completion("{\"status\": \"error\", \"message\": \"JSON conversion failed\"}")
|
|
511
|
+
}
|
|
512
|
+
return
|
|
500
513
|
}
|
|
501
514
|
}
|
|
502
515
|
|