omikit-plugin 3.2.89 → 3.2.90
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.
|
@@ -42,7 +42,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
42
42
|
ReactContextBaseJavaModule(reactContext), ActivityEventListener, OmiListener {
|
|
43
43
|
private val mainScope = CoroutineScope(Dispatchers.Main)
|
|
44
44
|
private var isIncoming: Boolean = false
|
|
45
|
-
private var
|
|
45
|
+
private var isAnswerCall: Boolean = false
|
|
46
46
|
|
|
47
47
|
override fun getName(): String {
|
|
48
48
|
return NAME
|
|
@@ -52,10 +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,
|
|
55
|
+
Log.d("OMISDK", "=>> incomingReceived CALLED - BEFORE: isIncoming: $isIncoming, isAnswerCall: $isAnswerCall")
|
|
56
56
|
isIncoming = true;
|
|
57
|
-
|
|
58
|
-
Log.d("OMISDK", "=>> incomingReceived AFTER SET - isIncoming: $isIncoming,
|
|
57
|
+
isAnswerCall = false; // Reset answer state for new incoming call
|
|
58
|
+
Log.d("OMISDK", "=>> incomingReceived AFTER SET - isIncoming: $isIncoming, isAnswerCall: $isAnswerCall, phoneNumber: $phoneNumber")
|
|
59
59
|
|
|
60
60
|
val typeNumber = OmiKitUtils().checkTypeNumber(phoneNumber ?: "")
|
|
61
61
|
|
|
@@ -78,7 +78,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
78
78
|
startTime: Long,
|
|
79
79
|
transactionId: String?,
|
|
80
80
|
) {
|
|
81
|
-
|
|
81
|
+
isAnswerCall = true
|
|
82
82
|
Log.d("OMISDK", "=>> ON CALL ESTABLISHED => ")
|
|
83
83
|
|
|
84
84
|
Handler(Looper.getMainLooper()).postDelayed({
|
|
@@ -102,13 +102,13 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
override fun onCallEnd(callInfo: MutableMap<String, Any?>, statusCode: Int) {
|
|
105
|
-
Log.d("OMISDK RN", "=>> onCallEnd CALLED - BEFORE RESET: isIncoming: $isIncoming,
|
|
105
|
+
Log.d("OMISDK RN", "=>> onCallEnd CALLED - BEFORE RESET: isIncoming: $isIncoming, isAnswerCall: $isAnswerCall")
|
|
106
106
|
Log.d("OMISDK RN", "=>> onCallEnd callInfo => $callInfo")
|
|
107
107
|
|
|
108
108
|
// Reset call state variables
|
|
109
109
|
isIncoming = false
|
|
110
|
-
|
|
111
|
-
Log.d("OMISDK", "=>> onCallEnd AFTER RESET - isIncoming: $isIncoming,
|
|
110
|
+
isAnswerCall = false
|
|
111
|
+
Log.d("OMISDK", "=>> onCallEnd AFTER RESET - isIncoming: $isIncoming, isAnswerCall: $isAnswerCall")
|
|
112
112
|
|
|
113
113
|
// Kiểm tra kiểu dữ liệu trước khi ép kiểu để tránh lỗi
|
|
114
114
|
val call = callInfo ?: mutableMapOf()
|
|
@@ -166,7 +166,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
166
166
|
val prePhoneNumber = OmiClient.prePhoneNumber ?: ""
|
|
167
167
|
val typeNumber = OmiKitUtils().checkTypeNumber(prePhoneNumber)
|
|
168
168
|
|
|
169
|
-
Log.d("OMISDK", "=>> onRinging CALLED - BEFORE: isIncoming: $isIncoming,
|
|
169
|
+
Log.d("OMISDK", "=>> onRinging CALLED - BEFORE: isIncoming: $isIncoming, isAnswerCall: $isAnswerCall, callDirection: $callDirection")
|
|
170
170
|
|
|
171
171
|
if (callDirection == "inbound") {
|
|
172
172
|
isIncoming = true;
|
|
@@ -176,7 +176,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
176
176
|
Log.d("OMISDK", "=>> onRinging SET isIncoming = false for outbound call")
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
Log.d("OMISDK", "=>> onRinging AFTER: isIncoming: $isIncoming,
|
|
179
|
+
Log.d("OMISDK", "=>> onRinging AFTER: isIncoming: $isIncoming, isAnswerCall: $isAnswerCall")
|
|
180
180
|
|
|
181
181
|
// ✅ Sử dụng safe WritableMap creation
|
|
182
182
|
val eventData = mapOf(
|
|
@@ -222,12 +222,12 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
override fun onOutgoingStarted(callerId: Int, phoneNumber: String?, isVideo: Boolean?) {
|
|
225
|
-
Log.d("OMISDK", "=>> onOutgoingStarted CALLED - BEFORE: isIncoming: $isIncoming,
|
|
225
|
+
Log.d("OMISDK", "=>> onOutgoingStarted CALLED - BEFORE: isIncoming: $isIncoming, isAnswerCall: $isAnswerCall")
|
|
226
226
|
|
|
227
227
|
// For outgoing calls, set states appropriately
|
|
228
228
|
isIncoming = false;
|
|
229
|
-
|
|
230
|
-
Log.d("OMISDK", "=>> onOutgoingStarted AFTER SET - isIncoming: $isIncoming,
|
|
229
|
+
isAnswerCall = false;
|
|
230
|
+
Log.d("OMISDK", "=>> onOutgoingStarted AFTER SET - isIncoming: $isIncoming, isAnswerCall: $isAnswerCall")
|
|
231
231
|
|
|
232
232
|
val typeNumber = OmiKitUtils().checkTypeNumber(phoneNumber ?: "")
|
|
233
233
|
|
|
@@ -832,7 +832,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
832
832
|
|
|
833
833
|
@ReactMethod
|
|
834
834
|
fun endCall(promise: Promise) {
|
|
835
|
-
if (isIncoming && !
|
|
835
|
+
if (isIncoming && !isAnswerCall) {
|
|
836
836
|
OmiClient.getInstance(reactApplicationContext!!).decline()
|
|
837
837
|
} else {
|
|
838
838
|
OmiClient.getInstance(reactApplicationContext!!).hangUp()
|
|
@@ -863,7 +863,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
863
863
|
|
|
864
864
|
@ReactMethod
|
|
865
865
|
fun dropCall(promise: Promise) {
|
|
866
|
-
if (isIncoming && !
|
|
866
|
+
if (isIncoming && !isAnswerCall) {
|
|
867
867
|
OmiClient.getInstance(reactApplicationContext!!).declineWithCode(false) // 603
|
|
868
868
|
} else {
|
|
869
869
|
OmiClient.getInstance(reactApplicationContext!!).hangUp()
|