omikit-plugin 3.2.50 → 3.2.52
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 +29 -2
- package/android/build.gradle +1 -1
- package/android/gradle.properties +2 -1
- package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +105 -56
- package/android/src/main/java/com/omikitplugin/constants/constant.kt +2 -0
- package/ios/CallProcess/CallManager.swift +544 -537
- package/ios/Constant/Constant.swift +1 -0
- package/ios/Library/OmikitNotification.m +1 -7
- package/ios/Library/OmikitPlugin.m +79 -64
- package/ios/Library/OmikitPlugin.swift +258 -202
- package/ios/OmikitPlugin.xcodeproj/project.pbxproj +0 -22
- package/lib/commonjs/omi_call_state.js +1 -0
- package/lib/commonjs/omi_call_state.js.map +1 -1
- package/lib/commonjs/omikit.js +10 -0
- package/lib/commonjs/omikit.js.map +1 -1
- package/lib/module/omi_call_state.js +1 -0
- package/lib/module/omi_call_state.js.map +1 -1
- package/lib/module/omikit.js +9 -0
- package/lib/module/omikit.js.map +1 -1
- package/omikit-plugin.podspec +8 -1
- package/package.json +1 -1
- package/src/omi_call_state.tsx +2 -1
- package/src/omikit.tsx +10 -0
- package/src/types/index.d.ts +3 -0
package/README.md
CHANGED
|
@@ -366,7 +366,16 @@ class MainActivity : ReactActivity() {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
```
|
|
369
|
+
- Tips: Error Use of undeclared identifier 'OmikitNotification' at file `AppDelegate.m`, please import this line below
|
|
369
370
|
|
|
371
|
+
```swift
|
|
372
|
+
#if __has_include("OmikitNotification.h")
|
|
373
|
+
#import "OmikitNotification.h"
|
|
374
|
+
#else
|
|
375
|
+
#import <omikit_plugin/OmikitNotification.h>
|
|
376
|
+
#endif
|
|
377
|
+
|
|
378
|
+
```
|
|
370
379
|
- Add these lines into `Info.plist`:
|
|
371
380
|
|
|
372
381
|
```swift
|
|
@@ -382,8 +391,9 @@ class MainActivity : ReactActivity() {
|
|
|
382
391
|
```swift
|
|
383
392
|
- (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)devToken
|
|
384
393
|
{
|
|
385
|
-
|
|
386
|
-
|
|
394
|
+
// parse token bytes to string
|
|
395
|
+
// const char *data = [devToken bytes];
|
|
396
|
+
const unsigned char *data = (const unsigned char *)[devToken bytes];
|
|
387
397
|
NSMutableString *token = [NSMutableString string];
|
|
388
398
|
for (NSUInteger i = 0; i < [devToken length]; i++)
|
|
389
399
|
{
|
|
@@ -417,6 +427,23 @@ We support 2 environments. So you need set correct key in Appdelegate.
|
|
|
417
427
|
|
|
418
428
|
\*Note: At Tab Build Setting off Target Project, you need set: **_Enable Modules (C and Objective C)_** : YES\*
|
|
419
429
|
|
|
430
|
+
#### Currently, OMICALL does not support React Native new architect.
|
|
431
|
+
Config turn Off for new architect
|
|
432
|
+
For iOS
|
|
433
|
+
```Ruby
|
|
434
|
+
use_react_native!(
|
|
435
|
+
:path => config[:reactNativePath],
|
|
436
|
+
:new_arch_enabled => false, // <=== add this line
|
|
437
|
+
... your config
|
|
438
|
+
)
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
For Android
|
|
442
|
+
Open file android/gradle.properties and add line below:
|
|
443
|
+
```kotlin
|
|
444
|
+
# Tắt New Architecture
|
|
445
|
+
newArchEnabled=false
|
|
446
|
+
```
|
|
420
447
|
#### iOS(Swift):
|
|
421
448
|
|
|
422
449
|
- Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
|
package/android/build.gradle
CHANGED
|
@@ -103,7 +103,7 @@ dependencies {
|
|
|
103
103
|
// use for OMISDK
|
|
104
104
|
implementation("androidx.work:work-runtime:2.8.1")
|
|
105
105
|
implementation "androidx.security:security-crypto:1.1.0-alpha06"
|
|
106
|
-
api 'vn.vihat.omicall:omi-sdk:2.3.
|
|
106
|
+
api 'vn.vihat.omicall:omi-sdk:2.3.14'
|
|
107
107
|
|
|
108
108
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
109
109
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
@@ -48,13 +48,13 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
48
48
|
override fun incomingReceived(callerId: Int?, phoneNumber: String?, isVideo: Boolean?) {
|
|
49
49
|
isIncomming = true;
|
|
50
50
|
Log.d("OMISDK", "=>> START INCOMING CALL REVICED => ")
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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(
|
|
@@ -158,9 +158,11 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
override fun onHold(isHold: Boolean) {
|
|
161
|
+
sendEvent(HOLD, isHold)
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
override fun onMuted(isMuted: Boolean) {
|
|
165
|
+
sendEvent(MUTED, isMuted)
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
override fun onOutgoingStarted(callerId: Int, phoneNumber: String?, isVideo: Boolean?) {
|
|
@@ -183,20 +185,33 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
183
185
|
|
|
184
186
|
override fun onRegisterCompleted(statusCode: Int) {
|
|
185
187
|
Log.d("OMISDK", "=> ON REGISTER COMPLETED => status code: $statusCode")
|
|
186
|
-
|
|
188
|
+
|
|
187
189
|
if (statusCode != 200) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
val mapObject = WritableNativeMap().apply {
|
|
191
|
+
putBoolean("isVideo", false)
|
|
192
|
+
putBoolean("incoming", true)
|
|
193
|
+
putString("callerNumber", "")
|
|
194
|
+
putString("_id", "")
|
|
195
|
+
putInt("status", 6)
|
|
196
|
+
putInt("code_end_call", if (statusCode == 403) 853 else statusCode)
|
|
197
|
+
}
|
|
198
|
+
sendEvent(CALL_STATE_CHANGED, mapObject)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
override fun onRequestPermission(permissions: Array<String>) {
|
|
203
|
+
|
|
204
|
+
val map = WritableNativeMap().apply {
|
|
205
|
+
putArray("permissions", WritableNativeArray().apply {
|
|
206
|
+
permissions.forEach {
|
|
207
|
+
pushString(it)
|
|
195
208
|
}
|
|
196
|
-
|
|
209
|
+
})
|
|
197
210
|
}
|
|
198
|
-
|
|
211
|
+
Log.d("OMISDK", "=>> onRequestPermission => $map")
|
|
212
|
+
sendEvent(REQUEST_PERMISSION, map)
|
|
199
213
|
|
|
214
|
+
}
|
|
200
215
|
|
|
201
216
|
override fun onVideoSize(width: Int, height: Int) {
|
|
202
217
|
|
|
@@ -285,7 +300,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
285
300
|
val audioNotificationDescription = data?.getString("audioNotificationDescription") ?: ""
|
|
286
301
|
val videoNotificationDescription = data?.getString("videoNotificationDescription") ?: ""
|
|
287
302
|
val displayNameType = data?.getString("displayNameType") ?: ""
|
|
288
|
-
val appRepresentName =
|
|
303
|
+
val appRepresentName = data?.getString("representName") ?: ""
|
|
289
304
|
|
|
290
305
|
|
|
291
306
|
OmiClient.getInstance(reactApplicationContext!!).configPushNotification(
|
|
@@ -304,7 +319,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
304
319
|
missedChannelName = "Cuộc gọi nhỡ",
|
|
305
320
|
displayNameType = userNameKey ?: "full_name",
|
|
306
321
|
notificationMissedCallPrefix = prefixMissedCallMessage ?: "Cuộc gọi nhỡ từ",
|
|
307
|
-
representName= appRepresentName ?: ""
|
|
322
|
+
representName = appRepresentName ?: ""
|
|
308
323
|
)
|
|
309
324
|
promise.resolve(true)
|
|
310
325
|
}
|
|
@@ -319,14 +334,22 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
319
334
|
val realm = data.getString("realm")
|
|
320
335
|
val host = data.getString("host") ?: "vh.omicrm.com"
|
|
321
336
|
val isVideo = data.getBoolean("isVideo")
|
|
322
|
-
val firebaseToken = data.getString("fcmToken")
|
|
337
|
+
val firebaseToken = data.getString("fcmToken")
|
|
323
338
|
val projectId = data.getString("projectId") ?: ""
|
|
324
339
|
|
|
325
340
|
withContext(Dispatchers.Default) {
|
|
326
341
|
try {
|
|
327
342
|
if (userName != null && password != null && realm != null && firebaseToken != null) {
|
|
328
343
|
loginResult =
|
|
329
|
-
OmiClient.register(
|
|
344
|
+
OmiClient.register(
|
|
345
|
+
userName,
|
|
346
|
+
password,
|
|
347
|
+
realm,
|
|
348
|
+
isVideo ?: true,
|
|
349
|
+
firebaseToken,
|
|
350
|
+
host,
|
|
351
|
+
projectId
|
|
352
|
+
)
|
|
330
353
|
promise.resolve(loginResult)
|
|
331
354
|
}
|
|
332
355
|
} catch (_: Throwable) {
|
|
@@ -394,20 +417,20 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
394
417
|
val statusPendingCall = OmiKitUtils().getStatusPendingCall(reactApplicationContext)
|
|
395
418
|
if (call.state == 3) {
|
|
396
419
|
if (statusPendingCall != 0) {
|
|
397
|
-
|
|
420
|
+
call.state = statusPendingCall
|
|
398
421
|
}
|
|
399
422
|
}
|
|
400
423
|
map.putBoolean("incoming", call.direction == "inbound")
|
|
401
424
|
map.putInt("_id", call.id)
|
|
402
|
-
map.putInt("status", call.state
|
|
425
|
+
map.putInt("status", call.state)
|
|
403
426
|
map.putBoolean("muted", false)
|
|
404
427
|
map.putBoolean("isVideo", call.isVideo ?: false)
|
|
405
428
|
promise.resolve(map)
|
|
406
|
-
if(
|
|
429
|
+
if (statusPendingCall == 2 && call.state != 5) {
|
|
407
430
|
Log.d("getInitialCall RN", "incomingReceive $statusPendingCall")
|
|
408
431
|
val map2: WritableMap = WritableNativeMap()
|
|
409
432
|
map2.putBoolean("isVideo", call.isVideo ?: false)
|
|
410
|
-
map2.putBoolean("incoming",true)
|
|
433
|
+
map2.putBoolean("incoming", true)
|
|
411
434
|
map2.putString("callerNumber", phoneNumberTemp)
|
|
412
435
|
map2.putString("_id", "")
|
|
413
436
|
map2.putInt("status", 2)
|
|
@@ -517,6 +540,29 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
517
540
|
}
|
|
518
541
|
}
|
|
519
542
|
|
|
543
|
+
|
|
544
|
+
@ReactMethod
|
|
545
|
+
fun toggleHold(promise: Promise) {
|
|
546
|
+
mainScope.launch {
|
|
547
|
+
try {
|
|
548
|
+
// Gọi hàm toggleHold() và kiểm tra kết quả
|
|
549
|
+
val result = withContext(Dispatchers.IO) {
|
|
550
|
+
OmiClient.getInstance(reactApplicationContext!!).toggleHold()
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// Kiểm tra nếu toggleHold trả về Unit
|
|
554
|
+
if (result == Unit) {
|
|
555
|
+
promise.resolve(null) // Trả về null nếu kết quả là Unit
|
|
556
|
+
} else {
|
|
557
|
+
promise.resolve(result)
|
|
558
|
+
}
|
|
559
|
+
} catch (e: Exception) {
|
|
560
|
+
promise.reject("TOGGLE_HOLD_EXCEPTION", "Exception occurred: ${e.message}", e)
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
520
566
|
@ReactMethod
|
|
521
567
|
fun toggleSpeaker(promise: Promise) {
|
|
522
568
|
currentActivity?.runOnUiThread {
|
|
@@ -625,28 +671,28 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
625
671
|
}
|
|
626
672
|
|
|
627
673
|
@ReactMethod
|
|
628
|
-
fun getUserInfo(phone: String, promise: Promise) {
|
|
674
|
+
fun getUserInfo(phone: String, promise: Promise) {
|
|
629
675
|
mainScope.launch {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
if (callResult != null && callResult is Map<*, *>) {
|
|
638
|
-
val call = callResult as Map<*, *>
|
|
639
|
-
val map: WritableMap = WritableNativeMap()
|
|
640
|
-
map.putString("extension", call["extension"] as String?)
|
|
641
|
-
map.putString("uuid", call["uuid"] as String?)
|
|
642
|
-
map.putString("full_name", call["full_name"] as String?)
|
|
643
|
-
map.putString("avatar_url", call["avatar_url"] as String?)
|
|
644
|
-
promise.resolve(map)
|
|
645
|
-
} else {
|
|
646
|
-
promise.resolve(null)
|
|
676
|
+
var callResult: Any? = null
|
|
677
|
+
withContext(Dispatchers.Default) {
|
|
678
|
+
try {
|
|
679
|
+
callResult = OmiClient.getInstance(reactApplicationContext!!).getUserInfo(phone)
|
|
680
|
+
} catch (_: Throwable) {
|
|
647
681
|
}
|
|
682
|
+
}
|
|
683
|
+
if (callResult != null && callResult is Map<*, *>) {
|
|
684
|
+
val call = callResult as Map<*, *>
|
|
685
|
+
val map: WritableMap = WritableNativeMap()
|
|
686
|
+
map.putString("extension", call["extension"] as String?)
|
|
687
|
+
map.putString("uuid", call["uuid"] as String?)
|
|
688
|
+
map.putString("full_name", call["full_name"] as String?)
|
|
689
|
+
map.putString("avatar_url", call["avatar_url"] as String?)
|
|
690
|
+
promise.resolve(map)
|
|
691
|
+
} else {
|
|
692
|
+
promise.resolve(null)
|
|
693
|
+
}
|
|
648
694
|
}
|
|
649
|
-
}
|
|
695
|
+
}
|
|
650
696
|
|
|
651
697
|
@ReactMethod
|
|
652
698
|
fun getAudio(promise: Promise) {
|
|
@@ -732,7 +778,7 @@ fun getUserInfo(phone: String, promise: Promise) {
|
|
|
732
778
|
val isAcceptedCall = intent.getBooleanExtra(
|
|
733
779
|
SipServiceConstants.ACTION_ACCEPT_INCOMING_CALL, false
|
|
734
780
|
)
|
|
735
|
-
if(isReopenCall){
|
|
781
|
+
if (isReopenCall) {
|
|
736
782
|
val activeCall = Utils.getActiveCall(context)
|
|
737
783
|
OmikitPluginModule(context).onCallEstablished(
|
|
738
784
|
activeCall?.id ?: 0,
|
|
@@ -754,14 +800,14 @@ fun getUserInfo(phone: String, promise: Promise) {
|
|
|
754
800
|
|
|
755
801
|
fun sendEvent(eventName: String?, params: Any?) {
|
|
756
802
|
if (eventName == null) {
|
|
757
|
-
|
|
758
|
-
|
|
803
|
+
Log.e("OmikitPlugin", "eventName is null. Event cannot be emitted.")
|
|
804
|
+
return
|
|
759
805
|
}
|
|
760
806
|
if (currentActivity != null) {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
807
|
+
currentActivity!!.runOnUiThread {
|
|
808
|
+
reactApplicationContext.getJSModule(RCTNativeAppEventEmitter::class.java)
|
|
809
|
+
.emit(eventName, params)
|
|
810
|
+
}
|
|
765
811
|
}
|
|
766
812
|
}
|
|
767
813
|
|
|
@@ -821,12 +867,15 @@ fun getUserInfo(phone: String, promise: Promise) {
|
|
|
821
867
|
}
|
|
822
868
|
|
|
823
869
|
override fun onNewIntent(p0: Intent?) {
|
|
824
|
-
if (p0 != null && p0.hasExtra(SipServiceConstants.
|
|
870
|
+
if (p0 != null && p0.hasExtra(SipServiceConstants.PARAM_IS_MISSED_CALL)) {
|
|
825
871
|
//do your Stuff
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
872
|
+
|
|
873
|
+
if (p0.getBooleanExtra(SipServiceConstants.PARAM_IS_MISSED_CALL, false)) {
|
|
874
|
+
val map: WritableMap = WritableNativeMap()
|
|
875
|
+
map.putString("callerNumber", p0.getStringExtra(SipServiceConstants.PARAM_NUMBER) ?: "")
|
|
876
|
+
map.putBoolean("isVideo", p0.getBooleanExtra(SipServiceConstants.PARAM_IS_VIDEO, false))
|
|
877
|
+
sendEvent(CLICK_MISSED_CALL, map)
|
|
878
|
+
}
|
|
830
879
|
}
|
|
831
880
|
}
|
|
832
881
|
}
|
|
@@ -34,6 +34,8 @@ 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
|
+
const val HOLD = "HOLD"
|
|
38
|
+
const val REQUEST_PERMISSION = "REQUEST_PERMISSION"
|
|
37
39
|
|
|
38
40
|
//PREFFERENCES
|
|
39
41
|
const val CURRENT_STATUS = "CURRENT_STATUS"
|