omikit-plugin 3.3.18 → 3.3.20
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
CHANGED
|
@@ -122,7 +122,7 @@ dependencies {
|
|
|
122
122
|
implementation("androidx.work:work-runtime:2.8.1")
|
|
123
123
|
implementation "androidx.security:security-crypto:1.1.0-alpha06"
|
|
124
124
|
// api 'vn.vihat.omicall:omi-sdk:2.3.23'
|
|
125
|
-
api "io.omicrm.vihat:omi-sdk:2.4.
|
|
125
|
+
api "io.omicrm.vihat:omi-sdk:2.4.6"
|
|
126
126
|
|
|
127
127
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
128
128
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
@@ -25,6 +25,8 @@ import kotlinx.coroutines.Dispatchers
|
|
|
25
25
|
import kotlinx.coroutines.launch
|
|
26
26
|
import kotlinx.coroutines.withContext
|
|
27
27
|
import kotlinx.coroutines.delay
|
|
28
|
+
import kotlinx.coroutines.sync.Mutex
|
|
29
|
+
import kotlinx.coroutines.sync.withLock
|
|
28
30
|
import vn.vihat.omicall.omisdk.OmiAccountListener
|
|
29
31
|
import vn.vihat.omicall.omisdk.OmiClient
|
|
30
32
|
import vn.vihat.omicall.omisdk.OmiListener
|
|
@@ -125,6 +127,9 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
125
127
|
private var lastCallTime: Long = 0
|
|
126
128
|
private val callCooldownMs: Long = 2000 // 2 seconds cooldown between calls
|
|
127
129
|
private val callStateLock = Any()
|
|
130
|
+
|
|
131
|
+
// Mutex for thread-safe OmiClient operations
|
|
132
|
+
private val omiClientMutex = Mutex()
|
|
128
133
|
|
|
129
134
|
override fun getName(): String {
|
|
130
135
|
return NAME
|
|
@@ -760,6 +765,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
760
765
|
|
|
761
766
|
@ReactMethod
|
|
762
767
|
fun initCallWithApiKey(data: ReadableMap, promise: Promise) {
|
|
768
|
+
Log.d("OmikitPlugin", "🔑 initCallWithApiKey called")
|
|
763
769
|
mainScope.launch {
|
|
764
770
|
var loginResult = false
|
|
765
771
|
val usrName = data.getString("fullName") ?: ""
|
|
@@ -769,47 +775,78 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
769
775
|
val phone = data.getString("phone")
|
|
770
776
|
val firebaseToken = data.getString("fcmToken") ?: ""
|
|
771
777
|
val projectId = data.getString("projectId") ?: ""
|
|
778
|
+
|
|
779
|
+
Log.d("OmikitPlugin", "🔑 Parameters - usrName: $usrName, usrUuid: $usrUuid, isVideo: $isVideo")
|
|
772
780
|
|
|
773
781
|
withContext(Dispatchers.Default) {
|
|
774
782
|
try {
|
|
783
|
+
Log.d("OmikitPlugin", "🔑 Starting validation")
|
|
775
784
|
// Validate required parameters
|
|
776
785
|
if (!ValidationHelper.validateRequired(mapOf(
|
|
777
786
|
"fullName" to usrName,
|
|
778
787
|
"usrUuid" to usrUuid,
|
|
779
788
|
"apiKey" to apiKey,
|
|
780
789
|
"fcmToken" to firebaseToken
|
|
781
|
-
), promise))
|
|
790
|
+
), promise)) {
|
|
791
|
+
Log.e("OmikitPlugin", "❌ Validation failed")
|
|
792
|
+
return@withContext
|
|
793
|
+
}
|
|
782
794
|
|
|
783
|
-
|
|
795
|
+
Log.d("OmikitPlugin", "✅ Validation passed")
|
|
796
|
+
|
|
797
|
+
// Check RECORD_AUDIO permission for Android 14+
|
|
798
|
+
val hasRecordAudio = ContextCompat.checkSelfPermission(
|
|
799
|
+
reactApplicationContext,
|
|
800
|
+
Manifest.permission.RECORD_AUDIO
|
|
801
|
+
) == PackageManager.PERMISSION_GRANTED
|
|
802
|
+
|
|
803
|
+
if (!hasRecordAudio) {
|
|
804
|
+
Log.e("OmikitPlugin", "❌ RECORD_AUDIO permission is required for Android 14+")
|
|
805
|
+
promise.resolve(false)
|
|
806
|
+
return@withContext
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
Log.d("OmikitPlugin", "✅ RECORD_AUDIO permission granted")
|
|
810
|
+
|
|
811
|
+
// ✅ Cleanup trước khi register với mutex
|
|
784
812
|
try {
|
|
785
|
-
|
|
786
|
-
|
|
813
|
+
Log.d("OmikitPlugin", "🧹 Starting cleanup")
|
|
814
|
+
omiClientMutex.withLock {
|
|
815
|
+
OmiClient.getInstance(reactApplicationContext!!).logout()
|
|
816
|
+
}
|
|
817
|
+
delay(1000) // Chờ cleanup hoàn tất
|
|
818
|
+
Log.d("OmikitPlugin", "✅ Cleanup completed")
|
|
787
819
|
} catch (e: Exception) {
|
|
788
820
|
Log.w("OmikitPlugin", "⚠️ Cleanup warning (expected): ${e.message}")
|
|
789
821
|
}
|
|
790
822
|
|
|
791
823
|
Log.d("OmikitPlugin", "🔑 Using API key registration for user: $usrName")
|
|
792
824
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
825
|
+
Log.d("OmikitPlugin", "🔑 Calling OmiClient.registerWithApiKey...")
|
|
826
|
+
omiClientMutex.withLock {
|
|
827
|
+
loginResult = OmiClient.registerWithApiKey(
|
|
828
|
+
apiKey ?: "",
|
|
829
|
+
usrName ?: "",
|
|
830
|
+
usrUuid ?: "",
|
|
831
|
+
phone ?: "",
|
|
832
|
+
isVideo,
|
|
833
|
+
firebaseToken,
|
|
834
|
+
projectId
|
|
835
|
+
)
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
Log.d("OmikitPlugin", "🔑 OmiClient.registerWithApiKey returned: $loginResult")
|
|
802
839
|
|
|
803
840
|
if (loginResult) {
|
|
804
841
|
Log.d("OmikitPlugin", "✅ API key registration successful")
|
|
805
842
|
promise.resolve(true)
|
|
806
843
|
} else {
|
|
807
844
|
Log.e("OmikitPlugin", "❌ API key registration failed")
|
|
808
|
-
promise.
|
|
845
|
+
promise.resolve(false)
|
|
809
846
|
}
|
|
810
847
|
} catch (e: Exception) {
|
|
811
848
|
Log.e("OmikitPlugin", "❌ Error during API key registration: ${e.message}", e)
|
|
812
|
-
promise.
|
|
849
|
+
promise.resolve(false)
|
|
813
850
|
}
|
|
814
851
|
}
|
|
815
852
|
}
|