omikit-plugin 3.2.88 → 3.2.89

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.
@@ -121,7 +121,7 @@ dependencies {
121
121
  implementation("androidx.work:work-runtime:2.8.1")
122
122
  implementation "androidx.security:security-crypto:1.1.0-alpha06"
123
123
  // api 'vn.vihat.omicall:omi-sdk:2.3.23'
124
- api "io.omicrm.vihat:omi-sdk:2.3.70"
124
+ api "io.omicrm.vihat:omi-sdk:2.3.71"
125
125
 
126
126
  implementation "com.facebook.react:react-native:+" // From node_modules
127
127
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@@ -52,7 +52,10 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
52
52
  private val handler = Handler(Looper.getMainLooper())
53
53
 
54
54
  override fun incomingReceived(callerId: Int?, phoneNumber: String?, isVideo: Boolean?) {
55
+ Log.d("OMISDK", "=>> incomingReceived CALLED - BEFORE: isIncoming: $isIncoming, isAnserCall: $isAnserCall")
55
56
  isIncoming = true;
57
+ isAnserCall = false; // Reset answer state for new incoming call
58
+ Log.d("OMISDK", "=>> incomingReceived AFTER SET - isIncoming: $isIncoming, isAnserCall: $isAnserCall, phoneNumber: $phoneNumber")
56
59
 
57
60
  val typeNumber = OmiKitUtils().checkTypeNumber(phoneNumber ?: "")
58
61
 
@@ -99,7 +102,13 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
99
102
  }
100
103
 
101
104
  override fun onCallEnd(callInfo: MutableMap<String, Any?>, statusCode: Int) {
102
- Log.d("OMISDK RN", "=>> onCallEnd 0000 => $callInfo")
105
+ Log.d("OMISDK RN", "=>> onCallEnd CALLED - BEFORE RESET: isIncoming: $isIncoming, isAnserCall: $isAnserCall")
106
+ Log.d("OMISDK RN", "=>> onCallEnd callInfo => $callInfo")
107
+
108
+ // Reset call state variables
109
+ isIncoming = false
110
+ isAnserCall = false
111
+ Log.d("OMISDK", "=>> onCallEnd AFTER RESET - isIncoming: $isIncoming, isAnserCall: $isAnserCall")
103
112
 
104
113
  // Kiểm tra kiểu dữ liệu trước khi ép kiểu để tránh lỗi
105
114
  val call = callInfo ?: mutableMapOf()
@@ -157,6 +166,18 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
157
166
  val prePhoneNumber = OmiClient.prePhoneNumber ?: ""
158
167
  val typeNumber = OmiKitUtils().checkTypeNumber(prePhoneNumber)
159
168
 
169
+ Log.d("OMISDK", "=>> onRinging CALLED - BEFORE: isIncoming: $isIncoming, isAnserCall: $isAnserCall, callDirection: $callDirection")
170
+
171
+ if (callDirection == "inbound") {
172
+ isIncoming = true;
173
+ Log.d("OMISDK", "=>> onRinging SET isIncoming = true for inbound call")
174
+ } else if (callDirection == "outbound") {
175
+ isIncoming = false;
176
+ Log.d("OMISDK", "=>> onRinging SET isIncoming = false for outbound call")
177
+ }
178
+
179
+ Log.d("OMISDK", "=>> onRinging AFTER: isIncoming: $isIncoming, isAnserCall: $isAnserCall")
180
+
160
181
  // ✅ Sử dụng safe WritableMap creation
161
182
  val eventData = mapOf(
162
183
  "callerNumber" to if (callDirection == "inbound") prePhoneNumber else "",
@@ -201,7 +222,12 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
201
222
  }
202
223
 
203
224
  override fun onOutgoingStarted(callerId: Int, phoneNumber: String?, isVideo: Boolean?) {
204
- Log.d("OMISDK", "=>> ON OUTGOING STARTED CALL => ")
225
+ Log.d("OMISDK", "=>> onOutgoingStarted CALLED - BEFORE: isIncoming: $isIncoming, isAnserCall: $isAnserCall")
226
+
227
+ // For outgoing calls, set states appropriately
228
+ isIncoming = false;
229
+ isAnserCall = false;
230
+ Log.d("OMISDK", "=>> onOutgoingStarted AFTER SET - isIncoming: $isIncoming, isAnserCall: $isAnserCall")
205
231
 
206
232
  val typeNumber = OmiKitUtils().checkTypeNumber(phoneNumber ?: "")
207
233
 
@@ -211,7 +237,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
211
237
  putString("transactionId", "")
212
238
  putInt("status", CallState.calling.value)
213
239
  putString("_id", "")
214
- putBoolean("incoming", isIncoming) // 🔹 Kiểm tra lỗi chính tả của biến này
240
+ putBoolean("incoming", isIncoming)
215
241
  putString("typeNumber", typeNumber)
216
242
  }
217
243
 
@@ -422,6 +448,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
422
448
  }
423
449
  }
424
450
 
451
+ @Suppress("MissingPermission")
425
452
  private fun isNetworkAvailable(): Boolean {
426
453
  return try {
427
454
  val connectivityManager = reactApplicationContext?.getSystemService(android.content.Context.CONNECTIVITY_SERVICE) as? android.net.ConnectivityManager
@@ -813,12 +840,25 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
813
840
  promise.resolve(true)
814
841
  }
815
842
 
816
- @ReactMethod
843
+ @ReactMethod
817
844
  fun rejectCall(promise: Promise) {
818
- if (isIncoming && !isAnserCall) {
819
- OmiClient.getInstance(reactApplicationContext!!).declineWithCode(true) // 486
820
- }
821
- promise.resolve(true)
845
+ Log.d("OMISDK", "➡️ rejectCall called - isIncoming: $isIncoming, isAnswerCall: $isAnswerCall")
846
+ if (isIncoming) {
847
+ Log.d("OMISDK", "📞 Incoming call")
848
+
849
+ if (!isAnswerCall) {
850
+ Log.d("OMISDK", "🚫 Declining call with declineWithCode(true)")
851
+ OmiClient.getInstance(reactApplicationContext!!).declineWithCode(true) // 486 Busy Here
852
+ } else {
853
+ Log.d("OMISDK", "📴 Call already answered, hanging up")
854
+ OmiClient.getInstance(reactApplicationContext!!).hangUp()
855
+ }
856
+
857
+ promise.resolve(true)
858
+ } else {
859
+ Log.d("OMISDK", "📤 Not incoming call, skipping reject")
860
+ promise.resolve(false)
861
+ }
822
862
  }
823
863
 
824
864
  @ReactMethod
@@ -35,7 +35,7 @@ Pod::Spec.new do |s|
35
35
  # Thêm dependency bắt buộc
36
36
  s.dependency "React-Core"
37
37
  # Sử dụng version OmiKit ổn định hơn
38
- s.dependency "OmiKit", "1.8.38"
38
+ s.dependency "OmiKit", "1.8.40"
39
39
 
40
40
 
41
41
  s.requires_arc = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omikit-plugin",
3
- "version": "3.2.88",
3
+ "version": "3.2.89",
4
4
  "description": "Omikit Plugin by ViHAT",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",