omikit-plugin 3.2.25 → 3.2.27

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/README.md CHANGED
@@ -144,14 +144,12 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
144
144
  <action android:name="android.intent.action.MAIN" />
145
145
  <category android:name="android.intent.category.LAUNCHER" />
146
146
  </intent-filter>
147
- <intent-filter>
148
- <action
149
- android:name="com.omicall.sdk.CallingActivity"
150
- android:launchMode="singleTask"
151
- android:largeHeap="true"
152
- android:alwaysRetainTaskState="true"
153
- />
154
- <category android:name="android.intent.category.DEFAULT" />
147
+ <intent-filter>
148
+ <action android:name="android.intent.action.CALL" />
149
+ <category android:name="android.intent.category.DEFAULT" />
150
+ <data
151
+ android:host="incoming_call"
152
+ android:scheme="omisdk" />
155
153
  </intent-filter>
156
154
  ..... // your config
157
155
  </activity>
@@ -180,10 +178,30 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
180
178
  ```
181
179
  public class MainActivity extends ReactActivity {
182
180
  ..... // your config
181
+
182
+
183
+ @Override
184
+ protected void onCreate(Bundle savedInstanceState) {
185
+ super.onCreate(savedInstanceState);
186
+ reactApplicationContext = new ReactApplicationContext(this);
187
+ }
188
+
189
+ @Override
190
+ public void onNewIntent(Intent intent) {
191
+ super.onNewIntent(intent);
192
+ if (intent != null) {
193
+ OmikitPluginModule.Companion.onGetIntentFromNotification(reactApplicationContext, intent, this);
194
+ }
195
+ }
196
+
183
197
  @Override
184
198
  protected void onResume() {
185
199
  super.onResume();
186
200
  OmikitPluginModule.Companion.onResume(this);
201
+ Intent intent = getIntent();
202
+ if (intent != null) {
203
+ OmikitPluginModule.Companion.onGetIntentFromNotification(reactApplicationContext, intent, this);
204
+ }
187
205
  ..... // your config
188
206
  }
189
207
  }
@@ -269,6 +287,15 @@ if (@available(iOS 10.0, *)) {
269
287
  }
270
288
  completionHandler();
271
289
  }
290
+
291
+ - (void)applicationWillTerminate:(UIApplication *)application {
292
+ @try {
293
+ [OmiClient OMICloseCall];
294
+ }
295
+ @catch (NSException *exception) {
296
+
297
+ }
298
+ }
272
299
  ```
273
300
 
274
301
  - Add these lines into `Info.plist`:
@@ -424,8 +451,9 @@ We need you request permission about call before make call:
424
451
  ```
425
452
  - OmiKit need FCM for Android and APNS to push notification on user devices. We use more packages: <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a>
426
453
 
427
- - Create OmiKit With ApiKey: OmiKit need apikey, username, user id to init environment(All information in innit is required). ViHAT Group will provide api key for you. Please contact for my sale:
428
- In This step, we need partner provide me fcmToken of firebase Message.
454
+ - Create OmiKit With ApiKey: OmiKit need apikey, username, user id to init environment(All information in innit is required). ViHAT Group will provide api key for you. This function is used when making calls from customers to switchboard numbers (not making internal calls).
455
+ Please contact for my sale:
456
+ In This step, we need partner provide me fcmToken of firebase Message.
429
457
  ```
430
458
  import { initCallWithApiKey } from 'omikit-plugin';
431
459
  import messaging from '@react-native-firebase/messaging';
@@ -449,7 +477,9 @@ We need you request permission about call before make call:
449
477
  //result is true then user login successfully.
450
478
  ```
451
479
 
452
- - Create OmiKit: OmiKit need userName, password, realm, fcmToken to init environment(All information in innit is required). ViHAT Group will provide information for you. Please contact for my sale:
480
+ - Create OmiKit: OmiKit need userName, password, realm, fcmToken to init environment(All information in innit is required). ViHAT Group will provide information for you.
481
+ This function is used when you want to call any telecommunication number, calling back and forth between internal groups.
482
+ Please contact for my sale:
453
483
 
454
484
  ```
455
485
  import { initCallWithUserPassword } from 'omikit-plugin';
@@ -807,4 +837,4 @@ useEffect(() => {
807
837
  example:
808
838
  transferCall({
809
839
  phoneNumber: 102
810
- })
840
+ })
@@ -104,7 +104,7 @@ dependencies {
104
104
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
105
105
  // noinspection GradleDynamicVersion
106
106
  // implementation "com.facebook.react:react-native"
107
- api 'vn.vihat.omicall:omi-sdk:2.1.46'
107
+ api 'vn.vihat.omicall:omi-sdk:2.2.40'
108
108
 
109
109
  implementation "com.facebook.react:react-native:+" // From node_modules
110
110
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@@ -120,7 +120,7 @@ dependencies {
120
120
  exclude module: 'okhttp'
121
121
  }
122
122
  implementation "com.squareup.retrofit2:converter-gson:2.9.0"
123
- implementation "com.squareup.okhttp3:okhttp:4.9.1"
123
+ implementation "com.squareup.okhttp3:okhttp:4.9.1"
124
124
  implementation "com.squareup.okhttp3:okhttp-urlconnection:4.9.1"
125
125
  implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
126
126
  implementation "com.google.code.gson:gson:2.8.9"
@@ -132,6 +132,7 @@ dependencies {
132
132
  implementation "com.github.bumptech.glide:glide:4.15.1"
133
133
  annotationProcessor "com.github.bumptech.glide:compiler:4.15.1"
134
134
  implementation("androidx.work:work-runtime:2.8.1")
135
+ implementation 'com.squareup.picasso:picasso:2.8'
135
136
 
136
137
  def coroutines_version = '1.7.2'
137
138
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
@@ -19,6 +19,7 @@ import com.facebook.react.bridge.*
19
19
  import com.facebook.react.modules.core.RCTNativeAppEventEmitter
20
20
  import com.omikitplugin.constants.*
21
21
  import com.omikitplugin.state.CallState
22
+ import com.omikitplugin.utils.OmiKitUtils
22
23
  import kotlinx.coroutines.CoroutineScope
23
24
  import kotlinx.coroutines.Dispatchers
24
25
  import kotlinx.coroutines.launch
@@ -27,34 +28,33 @@ import vn.vihat.omicall.omisdk.OmiAccountListener
27
28
  import vn.vihat.omicall.omisdk.OmiClient
28
29
  import vn.vihat.omicall.omisdk.OmiListener
29
30
  import vn.vihat.omicall.omisdk.service.NotificationService
31
+ import vn.vihat.omicall.omisdk.service.NotificationService.Companion.uuid
30
32
  import vn.vihat.omicall.omisdk.utils.OmiSDKUtils
31
33
  import vn.vihat.omicall.omisdk.utils.OmiStartCallStatus
32
34
  import vn.vihat.omicall.omisdk.utils.SipServiceConstants
35
+ import vn.vihat.omicall.omisdk.utils.Utils
33
36
 
34
37
 
35
38
  class OmikitPluginModule(reactContext: ReactApplicationContext?) :
36
39
  ReactContextBaseJavaModule(reactContext), ActivityEventListener, OmiListener {
37
40
  private val mainScope = CoroutineScope(Dispatchers.Main)
38
41
  private var isIncomming: Boolean = false
39
- private var callerNumberTemp: String = ""
40
42
  private var isAnserCall: Boolean = false
41
43
 
42
-
43
44
  override fun getName(): String {
44
45
  return NAME
45
46
  }
46
47
 
47
48
  override fun incomingReceived(callerId: Int?, phoneNumber: String?, isVideo: Boolean?) {
48
49
  isIncomming = true;
49
- Log.d("OMISDK", "=>> START IN COMMING CALL REVICED => ")
50
- val map: WritableMap = WritableNativeMap()
51
- map.putBoolean("isVideo", isVideo ?: true)
52
- map.putBoolean("incoming", isIncomming)
53
- map.putString("callerNumber", phoneNumber)
54
- map.putString("_id", "")
55
- map.putInt("status", CallState.incoming.value)
56
- sendEvent(CALL_STATE_CHANGED, map)
57
- Log.d("omikit", "incomingReceived: ")
50
+ Log.d("OMISDK", "=>> START INCOMING CALL REVICED => ")
51
+ val map: WritableMap = WritableNativeMap()
52
+ map.putBoolean("isVideo", isVideo ?: true)
53
+ map.putBoolean("incoming", isIncomming)
54
+ map.putString("callerNumber", phoneNumber)
55
+ map.putString("_id", "")
56
+ map.putInt("status", CallState.incoming.value)
57
+ sendEvent(CALL_STATE_CHANGED, map)
58
58
  }
59
59
 
60
60
  override fun onCallEstablished(
@@ -79,7 +79,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
79
79
  }
80
80
 
81
81
  override fun onCallEnd(callInfo: MutableMap<String, Any?>, statusCode: Int) {
82
- Log.d("OMISDK RN", "=>> onCallEnd 0000 => $callInfo")
82
+ Log.d("OMISDK RN", "=>> onCallEnd 0000 => $callInfo")
83
83
  val call = callInfo as Map<*, *>
84
84
  val map: WritableMap = WritableNativeMap()
85
85
  val timeStartToAnswer = call["time_start_to_answer"] as Long?
@@ -94,7 +94,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
94
94
  map.putString("disposition", call["disposition"] as String)
95
95
  map.putInt("status", CallState.disconnected.value)
96
96
  map.putInt("code_end_call", statusCode as Int)
97
- Log.d("OMISDK RN", "=>> onCallEnd => $map")
97
+ Log.d("OMISDK RN", "=>> onCallEnd => $map")
98
98
  sendEvent(CALL_STATE_CHANGED, map)
99
99
  }
100
100
 
@@ -110,12 +110,18 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
110
110
  sendEvent(CALL_STATE_CHANGED, map)
111
111
  }
112
112
 
113
+ override fun onDescriptionError() {
114
+ }
115
+
116
+ override fun onFcmReceived(uuid: String, userName: String, avatar: String) {
117
+ }
118
+
113
119
  override fun onRinging(callerId: Int, transactionId: String?) {
114
- var callDirection = OmiClient.callDirection
120
+ var callDirection = OmiClient.callDirection
115
121
  val map: WritableMap = WritableNativeMap()
116
122
 
117
- if(callDirection == "inbound") {
118
- Log.d("OMISDK", "=>> ON IN COMMING CALL => ")
123
+ if (callDirection == "inbound") {
124
+ Log.d("OMISDK", "=>> ON IN COMMING CALL => ")
119
125
  map.putString("callerNumber", OmiClient.prePhoneNumber)
120
126
  map.putBoolean("isVideo", NotificationService.isVideo)
121
127
  map.putBoolean("incoming", true)
@@ -165,7 +171,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
165
171
  map.putString("transactionId", "")
166
172
  map.putInt("status", CallState.calling.value)
167
173
  map.putString("_id", "")
168
- map.putBoolean("incoming",isIncomming)
174
+ map.putBoolean("incoming", isIncomming)
169
175
  sendEvent(CALL_STATE_CHANGED, map)
170
176
  }
171
177
 
@@ -175,8 +181,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
175
181
  sendEvent(SWITCHBOARD_ANSWER, map)
176
182
  }
177
183
 
178
- override fun onSlowRegister(){
179
- Log.d("Kds", "MainActivity -> callListener -> onSlowRegister")
184
+ override fun onRegisterCompleted(statusCode: Int) {
185
+ Log.d("OMISDK", "=>> ON REGISTER COMPLETED => status code $statusCode")
180
186
  }
181
187
 
182
188
 
@@ -234,15 +240,17 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
234
240
  @RequiresApi(Build.VERSION_CODES.M)
235
241
  @ReactMethod
236
242
  fun systemAlertWindow(promise: Promise) {
237
- val result = Settings.canDrawOverlays(reactApplicationContext)
238
- promise.resolve(result)
243
+ val result = Settings.canDrawOverlays(reactApplicationContext)
244
+ promise.resolve(result)
239
245
  }
240
246
 
241
247
  @RequiresApi(Build.VERSION_CODES.M)
242
248
  @ReactMethod
243
249
  fun openSystemAlertSetting(promise: Promise) {
244
- val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
245
- Uri.parse("package:" + reactApplicationContext.packageName))
250
+ val intent = Intent(
251
+ Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
252
+ Uri.parse("package:" + reactApplicationContext.packageName)
253
+ )
246
254
  intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
247
255
  reactApplicationContext.startActivity(intent)
248
256
  promise.resolve(true)
@@ -251,8 +259,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
251
259
  @ReactMethod
252
260
  fun configPushNotification(data: ReadableMap, promise: Promise) {
253
261
  currentActivity?.runOnUiThread {
254
- val notificationIcon = data.getString("notificationIcon") ?: ""
255
- val prefix = data?.getString("prefix") ?: ""
262
+ val notificationIcon = data.getString("notificationIcon") ?: ""
263
+ val prefix = data?.getString("prefix") ?: ""
256
264
  val incomingBackgroundColor = data?.getString("incomingBackgroundColor") ?: ""
257
265
  val incomingAcceptButtonImage = data?.getString("incomingAcceptButtonImage") ?: ""
258
266
  val incomingDeclineButtonImage = data?.getString("incomingDeclineButtonImage") ?: ""
@@ -276,9 +284,9 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
276
284
  inboundCallText = prefix,
277
285
  unknownContactText = "Cuộc gọi không xác định",
278
286
  showUUID = false,
279
- inboundChannelId = "${channelId}-inbound",
287
+ inboundChannelId = "${channelId}-inbound",
280
288
  inboundChannelName = "Cuộc gọi đến",
281
- missedChannelId = "${channelId}-missed",
289
+ missedChannelId = "${channelId}-missed",
282
290
  missedChannelName = "Cuộc gọi nhỡ",
283
291
  displayNameType = userNameKey ?: "full_name",
284
292
  notificationMissedCallPrefix = prefixMissedCallMessage ?: "Cuộc gọi nhỡ từ"
@@ -289,30 +297,34 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
289
297
 
290
298
  @ReactMethod
291
299
  fun initCallWithUserPassword(data: ReadableMap, promise: Promise) {
292
- mainScope.launch {
293
- var loginResult = false
294
- val userName = data.getString("userName")
295
- Log.d("dataOmi", "INIT_CALL_USER_PASSWORD ==>> $data ")
296
- Log.d("dataOmi", "INIT_CALL_USER_PASSWORD ==>> $userName ")
297
- val password = data.getString("password")
298
- val realm = data.getString("realm")
299
- val host = data.getString("host") ?: "vh.omicrm.com"
300
- val isVideo = data.getBoolean("isVideo")
301
- val firebaseToken = data.getString("fcmToken")
302
-
303
- Log.d("dataOmi", "INIT_CALL_USER_PASSWORD $userName -- $password --$realm --$isVideo -- $host")
304
-
305
- withContext(Dispatchers.Default) {
306
- try {
307
- if (userName != null && password != null && realm != null && firebaseToken != null) {
308
- loginResult = OmiClient.register(userName, password, realm , isVideo ?: true, firebaseToken, host)
309
- promise.resolve(loginResult)
310
- }
311
- } catch (_: Throwable) {
312
- promise.resolve(loginResult)
313
- }
300
+ mainScope.launch {
301
+ var loginResult = false
302
+ val userName = data.getString("userName")
303
+ Log.d("dataOmi", "INIT_CALL_USER_PASSWORD ==>> $data ")
304
+ Log.d("dataOmi", "INIT_CALL_USER_PASSWORD ==>> $userName ")
305
+ val password = data.getString("password")
306
+ val realm = data.getString("realm")
307
+ val host = data.getString("host") ?: "vh.omicrm.com"
308
+ val isVideo = data.getBoolean("isVideo")
309
+ val firebaseToken = data.getString("fcmToken")
310
+
311
+ Log.d(
312
+ "dataOmi",
313
+ "INIT_CALL_USER_PASSWORD $userName -- $password --$realm --$isVideo -- $host"
314
+ )
315
+
316
+ withContext(Dispatchers.Default) {
317
+ try {
318
+ if (userName != null && password != null && realm != null && firebaseToken != null) {
319
+ loginResult =
320
+ OmiClient.register(userName, password, realm, isVideo ?: true, firebaseToken, host)
321
+ promise.resolve(loginResult)
322
+ }
323
+ } catch (_: Throwable) {
324
+ promise.resolve(loginResult)
314
325
  }
315
- promise.resolve(loginResult)
326
+ }
327
+ promise.resolve(loginResult)
316
328
  }
317
329
  }
318
330
 
@@ -327,34 +339,33 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
327
339
  val phone = data.getString("phone")
328
340
  val firebaseToken = data.getString("fcmToken") as String
329
341
  requestPermission(isVideo)
330
- withContext(Dispatchers.Default) {
331
- try {
332
- if (usrName != null && usrUuid != null && apiKey != null && firebaseToken != null ) {
333
- loginResult = OmiClient.registerWithApiKey(
334
- apiKey = apiKey,
335
- userName = usrName,
336
- uuid = usrUuid,
337
- phone = phone ?: "",
338
- isVideo = isVideo,
339
- firebaseToken
340
- )
341
- promise.resolve(true)
342
- }
343
- } catch (_: Throwable) {
344
- promise.resolve(loginResult)
342
+ withContext(Dispatchers.Default) {
343
+ try {
344
+ if (usrName != null && usrUuid != null && apiKey != null && firebaseToken != null) {
345
+ loginResult = OmiClient.registerWithApiKey(
346
+ apiKey = apiKey,
347
+ userName = usrName,
348
+ uuid = usrUuid,
349
+ phone = phone ?: "",
350
+ isVideo = isVideo,
351
+ firebaseToken
352
+ )
353
+ promise.resolve(true)
354
+ }
355
+ } catch (_: Throwable) {
356
+ promise.resolve(loginResult)
345
357
  }
346
358
  }
347
359
 
348
360
  }
349
361
  }
350
362
 
351
-
352
363
  @ReactMethod
353
364
  fun getInitialCall(counter: Int = 4, promise: Promise) {
354
365
  currentActivity?.runOnUiThread {
355
- if (reactApplicationContext != null && OmiClient.getInstance(reactApplicationContext!!) != null) {
356
- val call = OmiClient.getInstance(reactApplicationContext!!).getCurrentCallInfo();
357
- Log.d("getInitialCall RN", "getInitialCall $call")
366
+ if (reactApplicationContext != null) {
367
+ val call = Utils.getActiveCall(reactApplicationContext!!)
368
+ Log.d("getInitialCall RN", "getInitialCall abc $call")
358
369
  if (call == null) {
359
370
  if (counter <= 0) {
360
371
  promise.resolve(false);
@@ -365,14 +376,32 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
365
376
  }
366
377
  }
367
378
  } else {
368
- var phoneNumberTemp: String = call["callerNumber"] as String
369
- if(phoneNumberTemp.isNotEmpty()){
379
+ val phoneNumberTemp: String = call.remoteNumber as String
380
+ if (phoneNumberTemp.isNotEmpty()) {
370
381
  val map: WritableMap = WritableNativeMap()
371
- map.putString("callerNumber", call["callerNumber"] as String)
372
- map.putInt("status", call["status"] as Int)
373
- map.putBoolean("muted", call["muted"] as Boolean)
374
- map.putBoolean("isVideo", call["isVideo"] as Boolean)
382
+ map.putString("callerNumber", phoneNumberTemp)
383
+ val statusPendingCall = OmiKitUtils().getStatusPendingCall(reactApplicationContext)
384
+ if (call.state == 3) {
385
+ if (statusPendingCall != 0) {
386
+ call.state = statusPendingCall
387
+ }
388
+ }
389
+ map.putBoolean("incoming", call.direction == "inbound")
390
+ map.putInt("_id", call.id)
391
+ map.putInt("status", call.state )
392
+ map.putBoolean("muted", false)
393
+ map.putBoolean("isVideo", call.isVideo ?: false)
375
394
  promise.resolve(map)
395
+ if( statusPendingCall == 2 && call.state !=5){
396
+ Log.d("getInitialCall RN", "incomingReceive $statusPendingCall")
397
+ val map2: WritableMap = WritableNativeMap()
398
+ map2.putBoolean("isVideo", call.isVideo ?: false)
399
+ map2.putBoolean("incoming",true)
400
+ map2.putString("callerNumber", phoneNumberTemp)
401
+ map2.putString("_id", "")
402
+ map2.putInt("status", 2)
403
+ sendEvent(CALL_STATE_CHANGED, map2)
404
+ }
376
405
  }
377
406
  }
378
407
  }
@@ -391,11 +420,12 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
391
420
  if (audio == PackageManager.PERMISSION_GRANTED) {
392
421
  currentActivity?.runOnUiThread {
393
422
  val phoneNumber = data.getString("phoneNumber") as String
394
- val isVideo = data.getBoolean("isVideo") ?: false ;
395
- val startCallResult = OmiClient.getInstance(reactApplicationContext!!).startCall(phoneNumber, isVideo)
396
- Log.d("OMISDK", "=>> startCallResult START CALL => $startCallResult")
397
- var statusCalltemp = startCallResult.value as Int;
398
- if(startCallResult.value == 200 ){
423
+ val isVideo = data.getBoolean("isVideo") ?: false;
424
+ val startCallResult =
425
+ OmiClient.getInstance(reactApplicationContext!!).startCall(phoneNumber, isVideo)
426
+ Log.d("OMISDK", "=>> startCallResult START CALL => $startCallResult")
427
+ var statusCalltemp = startCallResult.value as Int;
428
+ if (startCallResult.value == 200) {
399
429
  statusCalltemp = 8
400
430
  }
401
431
  map.putInt("status", statusCalltemp)
@@ -404,11 +434,11 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
404
434
  promise.resolve(map)
405
435
  }
406
436
  } else {
407
- map.putInt("status", 4)
408
- map.putString("_id", "")
409
- map.putString("message", messageCall(406) as String)
410
- Log.d("OMISDK", "=>> ON START CALL FAIL BECAUSE NEED PERMISSION => $map")
411
- promise.resolve(map)
437
+ map.putInt("status", 4)
438
+ map.putString("_id", "")
439
+ map.putString("message", messageCall(406) as String)
440
+ Log.d("OMISDK", "=>> ON START CALL FAIL BECAUSE NEED PERMISSION => $map")
441
+ promise.resolve(map)
412
442
  }
413
443
  }
414
444
 
@@ -426,7 +456,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
426
456
  try {
427
457
  val uuid = data.getString("usrUuid") as String
428
458
  val isVideo = data.getBoolean("isVideo")
429
- callResult = OmiClient.getInstance(reactApplicationContext!!).startCallWithUuid(uuid = uuid, isVideo = isVideo)
459
+ callResult = OmiClient.getInstance(reactApplicationContext!!)
460
+ .startCallWithUuid(uuid = uuid, isVideo = isVideo)
430
461
  } catch (_: Throwable) {
431
462
 
432
463
  }
@@ -441,21 +472,21 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
441
472
  @ReactMethod
442
473
  fun joinCall(promise: Promise) {
443
474
  currentActivity?.runOnUiThread {
444
- if(reactApplicationContext != null) {
445
- OmiClient.getInstance(reactApplicationContext!!).pickUp()
446
- promise.resolve(true)
475
+ if (reactApplicationContext != null) {
476
+ OmiClient.getInstance(reactApplicationContext!!).pickUp()
477
+ promise.resolve(true)
447
478
  }
448
479
  }
449
480
  }
450
481
 
451
482
  @ReactMethod
452
483
  fun endCall(promise: Promise) {
453
- if(isIncomming && !isAnserCall){
454
- OmiClient.getInstance(reactApplicationContext!!).decline()
484
+ if (isIncomming && !isAnserCall) {
485
+ OmiClient.getInstance(reactApplicationContext!!).decline()
455
486
  } else {
456
487
  OmiClient.getInstance(reactApplicationContext!!).hangUp()
457
488
  }
458
- promise.resolve(true)
489
+ promise.resolve(true)
459
490
 
460
491
  }
461
492
 
@@ -496,7 +527,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
496
527
  characterCode = 11
497
528
  }
498
529
  if (characterCode != null) {
499
- OmiClient.getInstance(reactApplicationContext!!).sendDtmf(characterCode)
530
+ OmiClient.getInstance(reactApplicationContext!!).sendDtmf(characterCode.toString())
500
531
  }
501
532
  promise.resolve(true)
502
533
  }
@@ -641,27 +672,26 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
641
672
  fun transferCall(data: ReadableMap, promise: Promise) {
642
673
  currentActivity?.runOnUiThread {
643
674
  val phone = data.getString("phoneNumber")
644
- Log.d("phone", "phone transferCall ==>> ${phone} ")
645
- if(reactApplicationContext != null) {
646
- Log.d("phone", "phone transferCall reactApplicationContext ==>> ${phone} ")
647
- OmiClient.getInstance(reactApplicationContext!!).forwardCallTo(phone as String)
648
- promise.resolve(true)
649
- }
675
+ Log.d("phone", "phone transferCall ==>> ${phone} ")
676
+ if (reactApplicationContext != null) {
677
+ Log.d("phone", "phone transferCall reactApplicationContext ==>> ${phone} ")
678
+ OmiClient.getInstance(reactApplicationContext!!).forwardCallTo(phone as String)
679
+ promise.resolve(true)
680
+ }
650
681
  }
651
682
  }
652
683
 
653
684
  companion object {
654
685
  const val NAME = "OmikitPlugin"
655
-
686
+
656
687
  fun onDestroy() {
657
688
 
658
689
  }
659
690
 
660
- fun onResume(act: ReactActivity) {
661
- act?.let { context ->
662
- if (!OmiClient.getInstance(context).isRegistering) {
663
- OmiClient.autoRegister(true);
664
- }
691
+ fun onResume(act: ReactActivity) {
692
+ act.let { context ->
693
+ Log.d("OMISDK_REACT", "=>> onResume => ")
694
+ OmiClient.getInstance(context, true)
665
695
  OmiClient.isAppReady = true;
666
696
  }
667
697
  }
@@ -676,9 +706,42 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
676
706
  OmiSDKUtils.handlePermissionRequest(requestCode, permissions, grantResults, act)
677
707
  }
678
708
  }
709
+
710
+ fun onGetIntentFromNotification(
711
+ context: ReactApplicationContext,
712
+ intent: Intent,
713
+ act: ReactActivity
714
+ ) {
715
+ act.runOnUiThread {
716
+ val isIncoming = intent.getBooleanExtra(SipServiceConstants.ACTION_IS_INCOMING_CALL, false)
717
+ if (!isIncoming) return@runOnUiThread
718
+ val isReopenCall = intent.getBooleanExtra(
719
+ SipServiceConstants.ACTION_REOPEN_CALL, false
720
+ )
721
+ val isAcceptedCall = intent.getBooleanExtra(
722
+ SipServiceConstants.ACTION_ACCEPT_INCOMING_CALL, false
723
+ )
724
+ if(isReopenCall){
725
+ val activeCall = Utils.getActiveCall(context)
726
+ OmikitPluginModule(context).onCallEstablished(
727
+ activeCall?.id ?: 0,
728
+ activeCall?.remoteNumber,
729
+ activeCall?.isVideo,
730
+ activeCall?.startTime ?: 0,
731
+ activeCall?.uuid
732
+ )
733
+ } else {
734
+ if (isAcceptedCall) {
735
+ OmiClient.getInstance(context).pickUp()
736
+ }
737
+ OmiKitUtils().setStatusPendingCall(context, isAcceptedCall)
738
+ }
739
+
740
+ }
741
+ }
679
742
  }
680
743
 
681
- private fun sendEvent(eventName: String?, params: Any?) {
744
+ fun sendEvent(eventName: String?, params: Any?) {
682
745
  if (currentActivity != null) {
683
746
  currentActivity!!.runOnUiThread {
684
747
  reactApplicationContext.getJSModule(RCTNativeAppEventEmitter::class.java)
@@ -707,8 +770,39 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
707
770
  )
708
771
  }
709
772
 
773
+ // private fun getPending(): {
774
+ // val pendingCall = OmiKitUtils().getPendingCall(reactApplicationContext)
775
+ // OmiKitUtils().clearPendingCall(reactApplicationContext)
776
+ // val isPending =
777
+ // pendingCall[PREFS_IS_PENDING] as Boolean
778
+ // val receiveTime = pendingCall[RECEIVE_TIME] as Long
779
+ //
780
+ // if ( isPending && System.currentTimeMillis() - receiveTime < 25000) {
781
+ // val callId = pendingCall[PREFS_CALL_ID] as Int
782
+ // val phoneNumber = pendingCall[PREFS_PHONE_NUMBER] as String
783
+ // val isVideo = pendingCall[PREFS_IS_VIDEO] as Boolean
784
+ // val startTime = pendingCall[PREFS_START_TIME] as Long
785
+ // val uuid = pendingCall[PREFS_UUID] as String
786
+ // val isReopen = pendingCall[PREFS_IS_REOPEN] as Boolean
787
+ // val isAccepted = pendingCall[PREFS_IS_ACCEPTED] as Boolean
788
+ //
789
+ // if (isReopen) {
790
+ // onCallEstablished(
791
+ // callId, phoneNumber, isVideo, startTime,
792
+ // uuid
793
+ // )
794
+ // } else if (isAccepted) {
795
+ // OmiClient.getInstance(reactApplicationContext!!).pickUp()
796
+ // onCallEstablished(
797
+ // callId, phoneNumber, isVideo, startTime,
798
+ // uuid
799
+ // )
800
+ // } else {
801
+ // incomingReceived(callId, phoneNumber, isVideo)
802
+ // }
803
+ // }
804
+ // }
710
805
  override fun onActivityResult(p0: Activity?, p1: Int, p2: Int, p3: Intent?) {
711
-
712
806
  }
713
807
 
714
808
  override fun onNewIntent(p0: Intent?) {
@@ -34,3 +34,7 @@ const val CLICK_MISSED_CALL = "CLICK_MISSED_CALL"
34
34
  const val SWITCHBOARD_ANSWER = "SWITCHBOARD_ANSWER"
35
35
  const val CALL_QUALITY = "CALL_QUALITY"
36
36
  const val AUDIO_CHANGE = "AUDIO_CHANGE"
37
+
38
+ //PREFFERENCES
39
+ const val CURRENT_STATUS = "CURRENT_STATUS"
40
+ const val RECEIVE_TIME = "RECEIVE_TIME"
@@ -0,0 +1,41 @@
1
+ package com.omikitplugin.utils
2
+
3
+ import android.content.Context
4
+ import com.omikitplugin.constants.CURRENT_STATUS
5
+ import com.omikitplugin.constants.RECEIVE_TIME
6
+
7
+ class OmiKitUtils {
8
+ fun setStatusPendingCall(
9
+ context: Context,
10
+ isAccepted: Boolean,
11
+ ) {
12
+ val sharedPreferences = context.getSharedPreferences("incomingcall", Context.MODE_PRIVATE)
13
+ val editor = sharedPreferences.edit()
14
+ val status = if (isAccepted) 5 else 2
15
+ editor.putInt(
16
+ CURRENT_STATUS, status
17
+ )
18
+ editor.putLong(
19
+ RECEIVE_TIME, System.currentTimeMillis()
20
+ )
21
+ editor.apply()
22
+ }
23
+
24
+ fun clearStatusPendingCall(context: Context) {
25
+ val sharedPreferences = context.getSharedPreferences("incomingcall", Context.MODE_PRIVATE)
26
+ val editor = sharedPreferences.edit()
27
+ editor.clear()
28
+ editor.apply()
29
+ }
30
+
31
+ fun getStatusPendingCall(context: Context): Int {
32
+ val sharedPreferences = context.getSharedPreferences("incomingcall", Context.MODE_PRIVATE)
33
+ val receiveTime = sharedPreferences.getLong(RECEIVE_TIME, 0)
34
+ if (receiveTime != 0L && System.currentTimeMillis() - receiveTime > 29000) {
35
+ clearStatusPendingCall(context)
36
+ }
37
+ val status = sharedPreferences.getInt(CURRENT_STATUS, 0)
38
+ clearStatusPendingCall(context)
39
+ return status
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>OmikitPlugin.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -20,7 +20,7 @@ Pod::Spec.new do |s|
20
20
 
21
21
  # Don't install the dependencies when we run `pod install` in the old architecture.
22
22
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
23
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" + " -fno-modules"
24
24
  s.pod_target_xcconfig = {
25
25
  "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
26
26
  "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
@@ -32,5 +32,5 @@ Pod::Spec.new do |s|
32
32
  s.dependency "RCTTypeSafety"
33
33
  s.dependency "ReactCommon/turbomodule/core"
34
34
  end
35
- s.dependency "OmiKit", '1.6.38'
35
+ s.dependency "OmiKit", '1.7.15'
36
36
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omikit-plugin",
3
- "version": "3.2.25",
3
+ "version": "3.2.27",
4
4
  "description": "Omikit Plugin by ViHAT",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",