omikit-plugin 3.0.2 → 3.0.4

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.
Files changed (36) hide show
  1. package/README.md +25 -3
  2. package/android/build.gradle +24 -9
  3. package/android/src/main/java/com/omikitplugin/FLLocalCameraView.kt +1 -1
  4. package/android/src/main/java/com/omikitplugin/FLRemoteCameraModule.kt +1 -1
  5. package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +161 -105
  6. package/android/src/main/java/com/omikitplugin/state/CallState.kt +7 -6
  7. package/ios/CallProcess/CallManager.swift +109 -47
  8. package/ios/CallProcess/CallState.swift +13 -1
  9. package/ios/CallProcess/OmiUtils.swift +53 -0
  10. package/ios/Model/OmiCallModel.swift +66 -0
  11. package/ios/Model/StartCalModel.swift +17 -0
  12. package/lib/commonjs/omi_call_state.js +10 -10
  13. package/lib/commonjs/omi_call_state.js.map +1 -1
  14. package/lib/commonjs/omi_local_camera.js.map +1 -1
  15. package/lib/commonjs/omi_remote_camera.js.map +1 -1
  16. package/lib/commonjs/omi_start_call_status.js +4 -4
  17. package/lib/commonjs/omi_start_call_status.js.map +1 -1
  18. package/lib/commonjs/omikit.js +1 -0
  19. package/lib/commonjs/omikit.js.map +1 -1
  20. package/lib/module/omi_call_state.js +10 -10
  21. package/lib/module/omi_call_state.js.map +1 -1
  22. package/lib/module/omi_local_camera.js.map +1 -1
  23. package/lib/module/omi_remote_camera.js.map +1 -1
  24. package/lib/module/omi_start_call_status.js +3 -3
  25. package/lib/module/omi_start_call_status.js.map +1 -1
  26. package/lib/module/omikit.js +1 -0
  27. package/lib/module/omikit.js.map +1 -1
  28. package/lib/typescript/omi_call_state.d.ts +7 -7
  29. package/lib/typescript/omi_call_state.d.ts.map +1 -1
  30. package/lib/typescript/omikit.d.ts +4 -4
  31. package/lib/typescript/omikit.d.ts.map +1 -1
  32. package/omikit-plugin.podspec +1 -1
  33. package/package.json +1 -1
  34. package/src/omi_call_state.tsx +7 -7
  35. package/src/omikit.tsx +5 -4
  36. package/CHANGELOG.md +0 -86
package/README.md CHANGED
@@ -657,10 +657,32 @@ useEffect(() => {
657
657
  ```
658
658
 
659
659
  - Important event `onCallStateChanged`: We provide it to listen call state change.
660
+ //OmiAction have 2 variables: actionName and data
661
+ ```
662
+ - Action Name value:
663
+ - `onCallStateChanged`: Call state changed.
664
+ - `onSwitchboardAnswer`: Switchboard sip is listening.
665
+ - List status call:
666
+ + unknown(0),
667
+ + calling(1),
668
+ + incoming(2),
669
+ + early(3),
670
+ + connecting(4),
671
+ + confirmed(5),
672
+ + disconnected(6);
673
+ + onCallStateChanged is call state tracking event. We will return status of state. Please refer `OmiCallState`.
674
+ `onCallStateChanged value:`
675
+ + isVideo: value boolean (true is call Video)
676
+ + status: number (value matching with List status call )
677
+ + callerNumber: phone number
678
+ + incoming: boolean - status call incoming or outgoing
679
+ + _id: option (id of every call)
680
+
681
+ + `Incoming call` state lifecycle: incoming -> connecting -> confirmed -> disconnected
682
+ + `Outgoing call` state lifecycle: calling -> early -> connecting -> confirmed -> disconnected
683
+
684
+ + onSwitchboardAnswer have callback when employee answered script call.
660
685
 
661
- + It is call state tracking event. We will return status of state. Please refer `OmiCallState`.
662
- + Incoming call state lifecycle: incoming(receive on foreround state) -> early -> connecting -> confirmed -> disconnected
663
- + Outgoing call state lifecycle: calling -> early (call created) -> connecting -> confirmed -> disconnected
664
686
 
665
687
  - Action Name value:
666
688
  - `OmiCallEvent.onMuted`: Audio changed.
@@ -15,12 +15,12 @@ buildscript {
15
15
  }
16
16
 
17
17
  dependencies {
18
- classpath "com.android.tools.build:gradle:7.2.1"
19
- // noinspection DifferentKotlinGradleVersion
18
+ classpath 'com.android.tools.build:gradle-api:7.1.2'
20
19
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
21
20
  classpath 'com.google.dagger:hilt-android-gradle-plugin:2.39.1'
22
21
  classpath 'com.github.kezong:fat-aar:1.3.8'
23
22
  classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.29.3"
23
+ classpath 'com.android.tools.build:gradle:4.0.0'
24
24
  }
25
25
  }
26
26
 
@@ -28,11 +28,12 @@ def isNewArchitectureEnabled() {
28
28
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
29
29
  }
30
30
 
31
- apply plugin: "com.android.library"
32
- apply plugin: "kotlin-android"
31
+ apply plugin: 'com.android.library'
32
+ apply plugin: 'kotlin-android'
33
33
  apply plugin: 'kotlin-kapt'
34
34
  apply plugin: 'kotlin-parcelize'
35
35
 
36
+
36
37
  if (isNewArchitectureEnabled()) {
37
38
  apply plugin: "com.facebook.react"
38
39
  }
@@ -68,6 +69,10 @@ android {
68
69
  targetCompatibility JavaVersion.VERSION_1_8
69
70
  }
70
71
 
72
+ // kotlinOptions {
73
+ // jvmTarget = '1.8'
74
+ // }
75
+
71
76
  dataBinding {
72
77
  enabled = true
73
78
  }
@@ -101,14 +106,15 @@ dependencies {
101
106
  // implementation "com.facebook.react:react-native"
102
107
  implementation "com.facebook.react:react-native:+" // From node_modules
103
108
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
104
-
105
- api 'vn.vihat.omicall:omi-sdk:1.4.49'
109
+ // implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
110
+ api 'vn.vihat.omicall:omi-sdk:2.0.19'
106
111
  // implementation fileTree(include: ['*.jar'], dir: 'libs')
107
112
  // implementation files('OmiSDK.aar')
108
- implementation 'androidx.appcompat:appcompat:1.5.0'
109
- implementation 'com.google.android.material:material:1.6.1'
113
+ implementation "com.google.android.flexbox:flexbox:3.0.0"
114
+ implementation "androidx.appcompat:appcompat:1.6.1"
115
+ implementation "androidx.lifecycle:lifecycle-process:2.6.1"
116
+ implementation "com.google.android.material:material:1.9.0"
110
117
  implementation 'com.google.firebase:firebase-messaging-ktx:23.1.2'
111
- implementation 'androidx.lifecycle:lifecycle-process:2.1.0'
112
118
  implementation("com.squareup.retrofit2:retrofit:2.9.0") {
113
119
  exclude module: 'okhttp'
114
120
  }
@@ -119,6 +125,15 @@ dependencies {
119
125
  implementation "com.google.code.gson:gson:2.8.9"
120
126
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
121
127
  implementation "androidx.security:security-crypto:1.1.0-alpha06"
128
+ implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
129
+ implementation "com.github.bumptech.glide:glide:4.15.1"
130
+ annotationProcessor "com.github.bumptech.glide:compiler:4.15.1"
131
+ implementation("androidx.work:work-runtime:2.8.1")
132
+
133
+ def coroutines_version = '1.7.2'
134
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
135
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
136
+
122
137
  }
123
138
 
124
139
  if (isNewArchitectureEnabled()) {
@@ -33,7 +33,7 @@ class FLLocalCameraView(private val context: ReactApplicationContext) :
33
33
 
34
34
  fun refreshTexture() {
35
35
  cameraView.surfaceTexture?.let {
36
- OmiClient.instance.setupLocalVideoFeed(Surface(it))
36
+ // OmiClient.getInstance().setupLocalVideoFeed(Surface(it))
37
37
  ScaleManager.adjustAspectRatio(
38
38
  cameraView,
39
39
  Size(cameraView.width, cameraView.height),
@@ -26,7 +26,7 @@ class FLRemoteCameraModule(reactContext: ReactApplicationContext, remoteViewMana
26
26
  @ReactMethod
27
27
  fun refresh(promise: Promise) {
28
28
  cameraView.surfaceTexture?.let {
29
- OmiClient.instance.setupIncomingVideoFeed(Surface(it))
29
+ // OmiClient.instance.setupIncomingVideoFeed(Surface(it))
30
30
  ScaleManager.adjustAspectRatio(cameraView,
31
31
  Size(cameraView.width, cameraView.height),
32
32
  Size(1280,720)
@@ -34,35 +34,45 @@ import vn.vihat.omicall.omisdk.utils.SipServiceConstants
34
34
  class OmikitPluginModule(reactContext: ReactApplicationContext?) :
35
35
  ReactContextBaseJavaModule(reactContext), ActivityEventListener, OmiListener {
36
36
  private val mainScope = CoroutineScope(Dispatchers.Main)
37
+ private var isIncomming: Boolean = false
38
+ private var callerNumberTemp: String = ""
39
+ private var isAnserCall: Boolean = false
40
+
37
41
 
38
42
  override fun getName(): String {
39
43
  return NAME
40
44
  }
41
45
 
42
46
  override fun incomingReceived(callerId: Int?, phoneNumber: String?, isVideo: Boolean?) {
47
+ isIncomming = true;
43
48
  val map: WritableMap = WritableNativeMap()
44
49
  map.putBoolean("isVideo", isVideo ?: true)
50
+ map.putBoolean("incoming", isIncomming)
45
51
  map.putString("callerNumber", phoneNumber)
52
+ map.putString("_id", "")
46
53
  map.putInt("status", CallState.incoming.value)
47
54
  sendEvent(CALL_STATE_CHANGED, map)
48
55
  Log.d("omikit", "incomingReceived: ")
49
56
  }
50
57
 
51
- override fun networkHealth(stat: Map<String, *>, quality: Int) {
52
- val map: WritableMap = WritableNativeMap()
53
- map.putInt("quality", quality)
54
- sendEvent(CALL_QUALITY, map)
55
- }
56
-
57
- override fun onAudioChanged(audioInfo: Map<String, Any>) {
58
- val audio: WritableMap = WritableNativeMap()
59
- audio.putString("name", audioInfo["name"] as String)
60
- audio.putInt("type", audioInfo["type"] as Int)
61
- val map: WritableMap = WritableNativeMap()
62
- val writeList = WritableNativeArray()
63
- writeList.pushMap(audio)
64
- map.putArray("data", writeList)
65
- sendEvent(AUDIO_CHANGE, map)
58
+ override fun onCallEstablished(
59
+ callerId: Int,
60
+ phoneNumber: String?,
61
+ isVideo: Boolean?,
62
+ startTime: Long,
63
+ transactionId: String?,
64
+ ) {
65
+ isAnserCall = true
66
+ Handler(Looper.getMainLooper()).postDelayed({
67
+ Log.d("OmikitReactNative", "onCallEstablished")
68
+ val map: WritableMap = WritableNativeMap()
69
+ map.putString("callerNumber", phoneNumber)
70
+ map.putBoolean("isVideo", isVideo ?: true)
71
+ map.putBoolean("incoming", isIncomming)
72
+ map.putString("transactionId", transactionId)
73
+ map.putInt("status", CallState.confirmed.value)
74
+ sendEvent(CALL_STATE_CHANGED, map)
75
+ }, 500)
66
76
  }
67
77
 
68
78
  override fun onCallEnd(callInfo: MutableMap<String, Any?>, statusCode: Int) {
@@ -82,33 +92,55 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
82
92
  sendEvent(CALL_STATE_CHANGED, map)
83
93
  }
84
94
 
85
- override fun onCallEstablished(
86
- callerId: Int,
87
- phoneNumber: String?,
88
- isVideo: Boolean?,
89
- startTime: Long,
90
- transactionId: String?,
91
- ) {
92
- Handler(Looper.getMainLooper()).postDelayed({
93
- Log.d("OmikitReactNative", "onCallEstablished")
94
- val map: WritableMap = WritableNativeMap()
95
- map.putString("callerNumber", phoneNumber)
96
- map.putBoolean("isVideo", isVideo ?: true)
97
- map.putString("transactionId", transactionId)
98
- map.putInt("status", CallState.confirmed.value)
99
- sendEvent(CALL_STATE_CHANGED, map)
100
- }, 500)
101
- }
102
-
103
95
  override fun onConnecting() {
104
96
  val map: WritableMap = WritableNativeMap()
105
97
  map.putString("callerNumber", "")
106
98
  map.putBoolean("isVideo", NotificationService.isVideo)
99
+ map.putBoolean("incoming", isIncomming)
107
100
  map.putString("transactionId", "")
101
+ map.putString("_id", "")
108
102
  map.putInt("status", CallState.connecting.value)
109
103
  sendEvent(CALL_STATE_CHANGED, map)
110
104
  }
111
105
 
106
+ override fun onRinging(callerId: Int, transactionId: String?) {
107
+ var callDirection = OmiClient.callDirection
108
+ val map: WritableMap = WritableNativeMap()
109
+
110
+ if(callDirection == "inbound") {
111
+ map.putString("callerNumber", OmiClient.prePhoneNumber)
112
+ map.putBoolean("isVideo", NotificationService.isVideo)
113
+ map.putBoolean("incoming", true)
114
+ map.putString("transactionId", transactionId ?: "")
115
+ map.putInt("status", CallState.incoming.value)
116
+ } else {
117
+ map.putString("callerNumber", "")
118
+ map.putBoolean("isVideo", NotificationService.isVideo)
119
+ map.putString("transactionId", transactionId ?: "")
120
+ map.putInt("status", CallState.early.value)
121
+ map.putBoolean("incoming", false)
122
+ }
123
+ sendEvent(CALL_STATE_CHANGED, map)
124
+ }
125
+
126
+
127
+ override fun networkHealth(stat: Map<String, *>, quality: Int) {
128
+ val map: WritableMap = WritableNativeMap()
129
+ map.putInt("quality", quality)
130
+ sendEvent(CALL_QUALITY, map)
131
+ }
132
+
133
+ override fun onAudioChanged(audioInfo: Map<String, Any>) {
134
+ val audio: WritableMap = WritableNativeMap()
135
+ audio.putString("name", audioInfo["name"] as String)
136
+ audio.putInt("type", audioInfo["type"] as Int)
137
+ val map: WritableMap = WritableNativeMap()
138
+ val writeList = WritableNativeArray()
139
+ writeList.pushMap(audio)
140
+ map.putArray("data", writeList)
141
+ sendEvent(AUDIO_CHANGE, map)
142
+ }
143
+
112
144
 
113
145
  override fun onHold(isHold: Boolean) {
114
146
  }
@@ -122,15 +154,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
122
154
  map.putBoolean("isVideo", NotificationService.isVideo)
123
155
  map.putString("transactionId", "")
124
156
  map.putInt("status", CallState.calling.value)
125
- sendEvent(CALL_STATE_CHANGED, map)
126
- }
127
-
128
- override fun onRinging(callerId: Int, transactionId: String?) {
129
- val map: WritableMap = WritableNativeMap()
130
- map.putString("callerNumber", "")
131
- map.putBoolean("isVideo", false)
132
- map.putString("transactionId", transactionId ?: "")
133
- map.putInt("status", CallState.early.value)
157
+ map.putString("_id", "")
158
+ map.putBoolean("incoming",isIncomming)
134
159
  sendEvent(CALL_STATE_CHANGED, map)
135
160
  }
136
161
 
@@ -150,18 +175,37 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
150
175
  }
151
176
  }
152
177
 
178
+ private fun messageCall(type: Int): String {
179
+ return when (type) {
180
+ 0 -> "INVALID_UUID"
181
+ 1 -> "INVALID_PHONE_NUMBER"
182
+ 2 -> "SAME_PHONE_NUMBER_WITH_PHONE_REGISTER"
183
+ 3 -> "MAX_RETRY"
184
+ 4 -> "PERMISSION_DENIED"
185
+ 5 -> "COULD_NOT_FIND_END_POINT"
186
+ 6 -> "REGISTER_ACCOUNT_FAIL"
187
+ 7 -> "START_CALL_FAIL"
188
+ 8 -> "START_CALL_SUCCESS"
189
+ 9 -> "HAVE_ANOTHER_CALL"
190
+ else -> "START_CALL_SUCCESS"
191
+ }
192
+ }
193
+
153
194
  override fun initialize() {
154
195
  super.initialize()
155
196
  reactApplicationContext!!.addActivityEventListener(this)
156
197
  Handler(Looper.getMainLooper()).post {
157
- OmiClient(context = reactApplicationContext!!)
158
- OmiClient.instance.addCallStateListener(this)
198
+ OmiClient(context = reactApplicationContext!!)
199
+ OmiClient.getInstance(reactApplicationContext!!).addCallStateListener(this)
200
+ OmiClient.getInstance(reactApplicationContext!!)
201
+ OmiClient.isAppReady = true;
202
+ OmiClient.getInstance(reactApplicationContext!!).addCallStateListener(this)
159
203
  }
160
204
  }
161
205
 
162
206
  @ReactMethod
163
207
  fun startServices(promise: Promise) {
164
- OmiClient.instance.addAccountListener(accountListener)
208
+ OmiClient.getInstance(reactApplicationContext!!).addAccountListener(accountListener)
165
209
  promise.resolve(true)
166
210
  }
167
211
 
@@ -185,34 +229,37 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
185
229
  @ReactMethod
186
230
  fun configPushNotification(data: ReadableMap, promise: Promise) {
187
231
  currentActivity?.runOnUiThread {
188
- val notificationIcon = data.getString("notificationIcon")
189
- val prefix = data.getString("prefix")
190
- val incomingBackgroundColor = data.getString("incomingBackgroundColor")
191
- val incomingAcceptButtonImage = data.getString("incomingAcceptButtonImage")
192
- val incomingDeclineButtonImage = data.getString("incomingDeclineButtonImage")
193
- val prefixMissedCallMessage = data.getString("prefixMissedCallMessage")
194
- val backImage = data.getString("backImage")
195
- val userImage = data.getString("userImage")
196
- val userNameKey = data.getString("userNameKey")
197
- val channelId = data.getString("channelId")
198
- val audioNotificationDescription = data.getString("audioNotificationDescription")
199
- val videoNotificationDescription = data.getString("videoNotificationDescription")
200
- OmiClient.instance.configPushNotification(
201
- notificationIcon = notificationIcon ?: "",
202
- prefix = prefix ?: "Cuộc gọi tới từ: ",
203
- incomingBackgroundColor = incomingBackgroundColor ?: "#FFFFFFFF",
204
- incomingAcceptButtonImage = incomingAcceptButtonImage ?: "join_call",
205
- incomingDeclineButtonImage = incomingDeclineButtonImage ?: "hangup",
206
- backImage = backImage ?: "ic_back",
207
- userImage = userImage ?: "calling_face",
208
- prefixMissedCallMessage = prefixMissedCallMessage ?: "Cuộc gọi nhỡ từ",
209
- userNameKey = userNameKey ?: "extension",
210
- channelId = channelId ?: "",
211
- ringtone = null,
212
- fullScreenUserImage = userImage ?: "calling_face",
213
- showUserInfoInFullScreen = false,
214
- audioNotificationDescription = audioNotificationDescription,
215
- videoNotificationDescription = videoNotificationDescription
232
+ val notificationIcon = data.getString("notificationIcon") ?: ""
233
+ val prefix = data?.getString("prefix") ?: ""
234
+ val incomingBackgroundColor = data?.getString("incomingBackgroundColor") ?: ""
235
+ val incomingAcceptButtonImage = data?.getString("incomingAcceptButtonImage") ?: ""
236
+ val incomingDeclineButtonImage = data?.getString("incomingDeclineButtonImage") ?: ""
237
+ val prefixMissedCallMessage = data?.getString("prefixMissedCallMessage") ?: ""
238
+ val backImage = data?.getString("backImage") ?: ""
239
+ val userImage = data?.getString("userImage") ?: ""
240
+ val userNameKey = data?.getString("userNameKey") ?: ""
241
+ val channelId = data?.getString("channelId") ?: ""
242
+ val missedCallTitle = data?.getString("missedCallTitle") ?: ""
243
+ val audioNotificationDescription = data?.getString("audioNotificationDescription") ?: ""
244
+ val videoNotificationDescription = data?.getString("videoNotificationDescription") ?: ""
245
+ val displayNameType = data?.getString("displayNameType") ?: ""
246
+
247
+ OmiClient.getInstance(reactApplicationContext!!).configPushNotification(
248
+ showMissedCall = true,
249
+ notificationIcon = notificationIcon ?: "ic_notification",
250
+ notificationAvatar = userImage ?: "ic_inbound_avatar_notification",
251
+ fullScreenAvatar = userImage ?: "ic_inbound_avatar_fullscreen",
252
+ internalCallText = "Gọi nội bộ",
253
+ videoCallText = "Gọi Video",
254
+ inboundCallText = prefix,
255
+ unknownContactText = "Cuộc gọi không xác định",
256
+ showUUID = false,
257
+ inboundChannelId = "${channelId}-inbound",
258
+ inboundChannelName = "Cuộc gọi đến",
259
+ missedChannelId = "${channelId}-missed",
260
+ missedChannelName = "Cuộc gọi nhỡ",
261
+ displayNameType = userNameKey ?: "full_name",
262
+ notificationMissedCallPrefix = prefixMissedCallMessage ?: "Cuộc gọi nhỡ từ"
216
263
  )
217
264
  promise.resolve(true)
218
265
  }
@@ -222,20 +269,17 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
222
269
  fun initCallWithUserPassword(data: ReadableMap, promise: Promise) {
223
270
  currentActivity?.runOnUiThread {
224
271
  val userName = data.getString("userName")
225
- val password = data.getString("password")
226
- val realm = data.getString("realm")
227
- val host = data.getString("host")
228
- val isVideo = data.getBoolean("isVideo")
229
- if (userName != null && password != null && realm != null && host != null) {
230
- OmiClient.register(
231
- userName,
232
- password,
233
- realm,
234
- isVideo,
235
- host,
236
- )
237
- }
238
- requestPermission(isVideo)
272
+ Log.d("dataOmi", "INIT_CALL_USER_PASSWORD ==>> $data ")
273
+ Log.d("dataOmi", "INIT_CALL_USER_PASSWORD ==>> $userName ")
274
+ val password = data.getString("password")
275
+ val realm = data.getString("realm")
276
+ val host = data.getString("host")
277
+ val isVideo = data.getBoolean("isVideo")
278
+ if (userName != null && password != null && realm != null && host != null) {
279
+ Log.d("dataOmi", "INIT_CALL_USER_PASSWORD $userName -- $password --$realm --$isVideo -- $host ")
280
+ OmiClient.register(userName, password, realm , isVideo ?: true, host)
281
+ }
282
+ // requestPermission(isVideo ?: true)
239
283
  promise.resolve(true)
240
284
  }
241
285
  }
@@ -249,6 +293,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
249
293
  val apiKey = data.getString("apiKey")
250
294
  val isVideo = data.getBoolean("isVideo")
251
295
  val phone = data.getString("phone")
296
+
252
297
  withContext(Dispatchers.Default) {
253
298
  try {
254
299
  if (usrName != null && usrUuid != null && apiKey != null) {
@@ -273,7 +318,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
273
318
  @ReactMethod
274
319
  fun getInitialCall(promise: Promise) {
275
320
  currentActivity?.runOnUiThread {
276
- val call = OmiClient.instance.getCurrentCallInfo()
321
+ val call = OmiClient.getInstance(reactApplicationContext!!).getCurrentCallInfo()
277
322
  if (call != null) {
278
323
  val map: WritableMap = WritableNativeMap()
279
324
  map.putString("callerNumber", call["callerNumber"] as String)
@@ -293,7 +338,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
293
338
  val deviceTokenAndroid = data.getString("fcmToken") as String
294
339
  withContext(Dispatchers.Default) {
295
340
  try {
296
- OmiClient.instance.updatePushToken(
341
+ OmiClient.getInstance(reactApplicationContext!!).updatePushToken(
297
342
  "",
298
343
  deviceTokenAndroid,
299
344
  )
@@ -312,14 +357,25 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
312
357
  reactApplicationContext!!,
313
358
  Manifest.permission.RECORD_AUDIO
314
359
  )
360
+ val map: WritableMap = WritableNativeMap()
315
361
  if (audio == PackageManager.PERMISSION_GRANTED) {
316
362
  currentActivity?.runOnUiThread {
317
363
  val phoneNumber = data.getString("phoneNumber") as String
318
364
  val isVideo = data.getBoolean("isVideo")
319
- OmiClient.instance.startCall(phoneNumber, isVideo)
365
+ val startCallResult = OmiClient.getInstance(reactApplicationContext!!).startCall(phoneNumber, isVideo)
366
+ Log.d("dataOmi", "startCall ==>> ${startCallResult} ")
367
+ Log.d("dataOmi", "startCall2 ==>> ${startCallResult.value} ")
368
+ // var status = startCallResult.value as String
369
+ // map.putString("status", startCallResult)
370
+ map.putString("_id", "")
371
+ // map.putString("message", startCallResult as String)
372
+ Log.d("dataOmi", "startCall ==>> ${map} ")
320
373
  promise.resolve(true)
321
374
  }
322
375
  } else {
376
+ map.putString("status","4")
377
+ map.putString("_id", "")
378
+ map.putString("message", messageCall(4) as String)
323
379
  promise.resolve(false)
324
380
  }
325
381
  }
@@ -338,7 +394,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
338
394
  try {
339
395
  val uuid = data.getString("usrUuid") as String
340
396
  val isVideo = data.getBoolean("isVideo")
341
- callResult = OmiClient.instance.startCallWithUuid(uuid = uuid, isVideo = isVideo)
397
+ callResult = OmiClient.getInstance(reactApplicationContext!!).startCallWithUuid(uuid = uuid, isVideo = isVideo)
342
398
  } catch (_: Throwable) {
343
399
 
344
400
  }
@@ -353,7 +409,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
353
409
  @ReactMethod
354
410
  fun joinCall(promise: Promise) {
355
411
  currentActivity?.runOnUiThread {
356
- OmiClient.instance.pickUp()
412
+ OmiClient.getInstance(reactApplicationContext!!).pickUp()
357
413
  promise.resolve(true)
358
414
  }
359
415
  }
@@ -361,7 +417,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
361
417
  @ReactMethod
362
418
  fun endCall(promise: Promise) {
363
419
  currentActivity?.runOnUiThread {
364
- val call = OmiClient.instance.hangUp()
420
+ val call = OmiClient.getInstance(reactApplicationContext!!).hangUp()
365
421
  val map: WritableMap = WritableNativeMap()
366
422
  val timeStartToAnswer = call?.get("time_start_to_answer") as Long?
367
423
  val timeEnd = call?.get("time_end") as Long
@@ -383,7 +439,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
383
439
  var newStatus: Boolean? = null
384
440
  withContext(Dispatchers.Default) {
385
441
  try {
386
- newStatus = OmiClient.instance.toggleMute()
442
+ newStatus = OmiClient.getInstance(reactApplicationContext!!).toggleMute()
387
443
  } catch (_: Throwable) {
388
444
 
389
445
  }
@@ -396,7 +452,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
396
452
  @ReactMethod
397
453
  fun toggleSpeaker(promise: Promise) {
398
454
  currentActivity?.runOnUiThread {
399
- val newStatus = OmiClient.instance.toggleSpeaker()
455
+ val newStatus = OmiClient.getInstance(reactApplicationContext!!).toggleSpeaker()
400
456
  promise.resolve(newStatus)
401
457
  sendEvent(SPEAKER, newStatus)
402
458
  }
@@ -414,7 +470,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
414
470
  characterCode = 11
415
471
  }
416
472
  if (characterCode != null) {
417
- OmiClient.instance.sendDtmf(characterCode)
473
+ OmiClient.getInstance(reactApplicationContext!!).sendDtmf(characterCode)
418
474
  }
419
475
  promise.resolve(true)
420
476
  }
@@ -423,7 +479,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
423
479
  @ReactMethod
424
480
  fun switchOmiCamera(promise: Promise) {
425
481
  currentActivity?.runOnUiThread {
426
- OmiClient.instance.switchCamera()
482
+ OmiClient.getInstance(reactApplicationContext!!).switchCamera()
427
483
  promise.resolve(true)
428
484
  }
429
485
  }
@@ -431,7 +487,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
431
487
  @ReactMethod
432
488
  fun toggleOmiVideo(promise: Promise) {
433
489
  currentActivity?.runOnUiThread {
434
- OmiClient.instance.toggleCamera()
490
+ OmiClient.getInstance(reactApplicationContext!!).toggleCamera()
435
491
  promise.resolve(true)
436
492
  }
437
493
  }
@@ -441,7 +497,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
441
497
  mainScope.launch {
442
498
  withContext(Dispatchers.Default) {
443
499
  try {
444
- OmiClient.instance.logout()
500
+ OmiClient.getInstance(reactApplicationContext!!).logout()
445
501
  } catch (_: Throwable) {
446
502
 
447
503
  }
@@ -456,7 +512,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
456
512
  var callResult: Any? = null
457
513
  withContext(Dispatchers.Default) {
458
514
  try {
459
- callResult = OmiClient.instance.getCurrentUser()
515
+ callResult = OmiClient.getInstance(reactApplicationContext!!).getCurrentUser()
460
516
  } catch (_: Throwable) {
461
517
 
462
518
  }
@@ -481,7 +537,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
481
537
  var callResult: Any? = null
482
538
  withContext(Dispatchers.Default) {
483
539
  try {
484
- callResult = OmiClient.instance.getIncomingCallUser()
540
+ callResult = OmiClient.getInstance(reactApplicationContext!!).getIncomingCallUser()
485
541
  } catch (_: Throwable) {
486
542
 
487
543
  }
@@ -506,7 +562,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
506
562
  var callResult: Any? = null
507
563
  withContext(Dispatchers.Default) {
508
564
  try {
509
- callResult = OmiClient.instance.getUserInfo(phone as String)
565
+ callResult = OmiClient.getInstance(reactApplicationContext!!).getUserInfo(phone as String)
510
566
  } catch (_: Throwable) {
511
567
  }
512
568
  }
@@ -526,7 +582,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
526
582
 
527
583
  @ReactMethod
528
584
  fun getAudio(promise: Promise) {
529
- val inputs = OmiClient.instance.getAudioOutputs()
585
+ val inputs = OmiClient.getInstance(reactApplicationContext!!).getAudioOutputs()
530
586
  val writeList = WritableNativeArray()
531
587
  inputs.forEach {
532
588
  val map = WritableNativeMap()
@@ -539,7 +595,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
539
595
 
540
596
  @ReactMethod
541
597
  fun getCurrentAudio(promise: Promise) {
542
- val currentAudio = OmiClient.instance.getCurrentAudio()
598
+ val currentAudio = OmiClient.getInstance(reactApplicationContext!!).getCurrentAudio()
543
599
  val map: WritableMap = WritableNativeMap()
544
600
  map.putString("name", currentAudio["name"] as String)
545
601
  map.putInt("type", currentAudio["type"] as Int)
@@ -551,7 +607,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
551
607
  @ReactMethod
552
608
  fun setAudio(data: ReadableMap, promise: Promise) {
553
609
  val portType = data.getInt("portType")
554
- OmiClient.instance.setAudio(portType)
610
+ OmiClient.getInstance(reactApplicationContext!!).setAudio(portType)
555
611
  promise.resolve(true)
556
612
  }
557
613
 
@@ -1,12 +1,13 @@
1
1
  package com.omikitplugin.state
2
2
 
3
3
  enum class CallState(_value: Int) {
4
- calling(0),
5
- early(1),
6
- connecting(2),
7
- confirmed(3),
8
- incoming(4),
9
- disconnected(5);
4
+ unknown(0),
5
+ calling(1),
6
+ incoming(2),
7
+ early(3),
8
+ connecting(4),
9
+ confirmed(5),
10
+ disconnected(6);
10
11
 
11
12
  val value = _value
12
13
  }