omikit-plugin 2.4.0 → 3.0.1
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 +77 -35
- package/android/build.gradle +9 -6
- package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +73 -42
- package/android/src/main/java/com/omikitplugin/constants/constant.kt +1 -0
- package/ios/CallProcess/CallManager.swift +151 -181
- package/ios/CallProcess/CallState.swift +1 -0
- package/ios/Constant/Constant.swift +1 -1
- package/ios/Library/OmikitPlugin.m +18 -0
- package/ios/Library/OmikitPlugin.swift +41 -15
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/omi_call_state.js +1 -0
- package/lib/commonjs/omi_call_state.js.map +1 -1
- package/lib/commonjs/omi_start_call_status.js +21 -0
- package/lib/commonjs/omi_start_call_status.js.map +1 -0
- package/lib/commonjs/omikit.js +14 -6
- package/lib/commonjs/omikit.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.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/omi_start_call_status.js +14 -0
- package/lib/module/omi_start_call_status.js.map +1 -0
- package/lib/module/omikit.js +11 -6
- package/lib/module/omikit.js.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/omi_call_state.d.ts +2 -1
- package/lib/typescript/omi_call_state.d.ts.map +1 -1
- package/lib/typescript/omi_start_call_status.d.ts +13 -0
- package/lib/typescript/omi_start_call_status.d.ts.map +1 -0
- package/lib/typescript/omikit.d.ts +6 -2
- package/lib/typescript/omikit.d.ts.map +1 -1
- package/omikit-plugin.podspec +1 -1
- package/package.json +1 -1
- package/src/index.tsx +1 -0
- package/src/omi_call_state.tsx +1 -0
- package/src/omi_start_call_status.tsx +12 -0
- package/src/omikit.tsx +15 -7
package/README.md
CHANGED
|
@@ -36,10 +36,13 @@ yarn add omikit-plugin --latest
|
|
|
36
36
|
```
|
|
37
37
|
jcenter()
|
|
38
38
|
maven {
|
|
39
|
-
url
|
|
40
|
-
credentials {
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
url "https://gitlab.com/api/v4/projects/47675059/packages/maven"
|
|
40
|
+
credentials(HttpHeaderCredentials) {
|
|
41
|
+
name = "Private-Token"
|
|
42
|
+
value = "glpat-AzyyrvKz9_pjsgGW4xfp"
|
|
43
|
+
}
|
|
44
|
+
authentication {
|
|
45
|
+
header(HttpHeaderAuthentication)
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
```
|
|
@@ -71,11 +74,14 @@ allprojects {
|
|
|
71
74
|
google()
|
|
72
75
|
maven { url 'https://www.jitpack.io' }
|
|
73
76
|
maven {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
url "https://gitlab.com/api/v4/projects/47675059/packages/maven"
|
|
78
|
+
credentials(HttpHeaderCredentials) {
|
|
79
|
+
name = "Private-Token"
|
|
80
|
+
value = "glpat-AzyyrvKz9_pjsgGW4xfp"
|
|
81
|
+
}
|
|
82
|
+
authentication {
|
|
83
|
+
header(HttpHeaderAuthentication)
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
@@ -96,21 +102,26 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
|
|
|
96
102
|
|
|
97
103
|
```
|
|
98
104
|
//need request this permission
|
|
105
|
+
//need request this permission
|
|
99
106
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
100
|
-
//add
|
|
107
|
+
//add these lines inside <activity>
|
|
101
108
|
<intent-filter>
|
|
102
109
|
<action android:name="com.omicall.sdk.CallingActivity"/>
|
|
103
110
|
<category android:name="android.intent.category.DEFAULT" />
|
|
104
111
|
</intent-filter>
|
|
105
|
-
//add
|
|
112
|
+
//add these lines outside <activity>
|
|
106
113
|
<receiver
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
android:name="vn.vihat.omicall.omisdk.receiver.FirebaseMessageReceiver"
|
|
115
|
+
android:exported="true"
|
|
116
|
+
android:permission="com.google.android.c2dm.permission.SEND">
|
|
117
|
+
<intent-filter>
|
|
118
|
+
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
|
119
|
+
</intent-filter>
|
|
113
120
|
</receiver>
|
|
121
|
+
<service
|
|
122
|
+
android:name="vn.vihat.omicall.omisdk.service.NotificationService"
|
|
123
|
+
android:exported="false">
|
|
124
|
+
</service>
|
|
114
125
|
```
|
|
115
126
|
|
|
116
127
|
You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blob/main/example/android/app/src/main/AndroidManifest.xml">AndroidManifest</a> to know more informations.
|
|
@@ -130,7 +141,6 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
|
|
|
130
141
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
|
131
142
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
132
143
|
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
|
133
|
-
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
134
144
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
|
135
145
|
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
|
136
146
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
@@ -139,12 +149,14 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
|
|
|
139
149
|
- Setup remote push notification: Only support Firebase for remote push notification.
|
|
140
150
|
|
|
141
151
|
- Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
|
|
142
|
-
- Add
|
|
152
|
+
- Add Firebase Messaging to receive `fcm_token` (You can refer <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> to setup notification for React native)
|
|
143
153
|
|
|
144
154
|
- For more setting information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/android-sdk/cau-hinh-push-notification">Config Push for Android</a>
|
|
145
155
|
|
|
146
156
|
#### iOS(Object-C):
|
|
147
157
|
|
|
158
|
+
- Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
|
|
159
|
+
|
|
148
160
|
- Add variables in Appdelegate.h:
|
|
149
161
|
|
|
150
162
|
```
|
|
@@ -169,7 +181,7 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
|
|
|
169
181
|
#import <OmiKit/OmiKit.h>
|
|
170
182
|
#import <omicall_flutter_plugin/omicall_flutter_plugin-Swift.h>
|
|
171
183
|
|
|
172
|
-
[OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX];
|
|
184
|
+
[OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX userNameKey:@"full_name" maxCall:2 callKitImage:@"call_image"];
|
|
173
185
|
provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
|
|
174
186
|
voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
|
|
175
187
|
pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
@@ -234,7 +246,16 @@ if (@available(iOS 10.0, *)) {
|
|
|
234
246
|
|
|
235
247
|
- For more setting information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/ios-sdk/cau-hinh-push-notification">Config Push for iOS</a>
|
|
236
248
|
|
|
249
|
+
*** Important release note ***
|
|
250
|
+
```
|
|
251
|
+
We support 2 environments. So you need set correct key in Appdelegate.
|
|
252
|
+
- KEY_OMI_APP_ENVIROMENT_SANDBOX support on debug mode
|
|
253
|
+
- KEY_OMI_APP_ENVIROMENT_PRODUCTION support on release mode
|
|
254
|
+
- Visit on web admin to select correct enviroment.
|
|
255
|
+
```
|
|
256
|
+
|
|
237
257
|
#### iOS(Swift):
|
|
258
|
+
- Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
|
|
238
259
|
|
|
239
260
|
- Add variables in Appdelegate.swift:
|
|
240
261
|
|
|
@@ -251,7 +272,7 @@ var voipRegistry: PKPushRegistry?
|
|
|
251
272
|
- Add these lines into `didFinishLaunchingWithOptions`:
|
|
252
273
|
|
|
253
274
|
```
|
|
254
|
-
OmiClient.setEnviroment(KEY_OMI_APP_ENVIROMENT_SANDBOX)
|
|
275
|
+
OmiClient.setEnviroment(KEY_OMI_APP_ENVIROMENT_SANDBOX, userNameKey: "extension", maxCall: 1, callKitImage: "call_image")
|
|
255
276
|
provider = CallKitProviderDelegate.init(callManager: OMISIPLib.sharedInstance().callManager)
|
|
256
277
|
voipRegistry = PKPushRegistry.init(queue: .main)
|
|
257
278
|
pushkitManager = PushKitManager.init(voipRegistry: voipRegistry)
|
|
@@ -290,6 +311,13 @@ extension Data {
|
|
|
290
311
|
- Add Firebase Messaging to receive `fcm_token` (You can refer <a href="https://pub.dev/packages/firebase_messaging">Cloud Messaging</a> to setup notification for React Native)
|
|
291
312
|
|
|
292
313
|
- For more setting information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/ios-sdk/cau-hinh-push-notification">Config Push for iOS</a>
|
|
314
|
+
*** Important release note ***
|
|
315
|
+
```
|
|
316
|
+
We support 2 environments. So you need set correct key in Appdelegate.
|
|
317
|
+
- KEY_OMI_APP_ENVIROMENT_SANDBOX support on debug mode
|
|
318
|
+
- KEY_OMI_APP_ENVIROMENT_PRODUCTION support on release mode
|
|
319
|
+
- Visit on web admin to select correct enviroment.
|
|
320
|
+
```
|
|
293
321
|
|
|
294
322
|
|
|
295
323
|
## Implement
|
|
@@ -322,9 +350,9 @@ extension Data {
|
|
|
322
350
|
usrUuid: usrUuid,
|
|
323
351
|
fullName: fullName,
|
|
324
352
|
apiKey: apiKey,
|
|
353
|
+
phone: phone,
|
|
325
354
|
isVideo: isVideo,
|
|
326
355
|
};
|
|
327
|
-
console.log(loginInfo);
|
|
328
356
|
const result = await initCallWithApiKey(loginInfo);
|
|
329
357
|
//result is true then user login successfully.
|
|
330
358
|
```
|
|
@@ -362,22 +390,12 @@ extension Data {
|
|
|
362
390
|
missedCallTitle: 'Cuộc gọi nhỡ', //config title for the missed call
|
|
363
391
|
userNameKey: 'uuid', //we have 3 values: uuid, full_name, extension.
|
|
364
392
|
channelId: 'com.channel.sample', //your notification channel id
|
|
393
|
+
audioNotificationDescription: '' //audio description
|
|
394
|
+
videoNotificationDescription: '' //video descriptipn
|
|
365
395
|
});
|
|
366
396
|
//incomingAcceptButtonImage, incomingDeclineButtonImage, backImage, userImage: Add these into `android/app/src/main/res/drawble`
|
|
367
397
|
```
|
|
368
398
|
|
|
369
|
-
- Get call when user open app from killed state(only iOS):
|
|
370
|
-
|
|
371
|
-
```
|
|
372
|
-
import { getInitialCall } from 'omikit-plugin';
|
|
373
|
-
|
|
374
|
-
const callingInfo = await getInitialCall();
|
|
375
|
-
if (callingInfo !== false) {
|
|
376
|
-
navigation.navigate('DialCall' as never, callingInfo as never);
|
|
377
|
-
}
|
|
378
|
-
//callingInfo != false then user have a calling.
|
|
379
|
-
```
|
|
380
|
-
|
|
381
399
|
- Upload token: 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> and <a href="https://www.npmjs.com/package/react-native-device-info?activeTab=readme">react-native-device-info</a>
|
|
382
400
|
|
|
383
401
|
```
|
|
@@ -394,6 +412,18 @@ extension Data {
|
|
|
394
412
|
});
|
|
395
413
|
```
|
|
396
414
|
|
|
415
|
+
- Get call when user open application at first time:
|
|
416
|
+
|
|
417
|
+
```
|
|
418
|
+
import { getInitialCall } from 'omikit-plugin';
|
|
419
|
+
|
|
420
|
+
const callingInfo = await getInitialCall();
|
|
421
|
+
if (callingInfo !== false) {
|
|
422
|
+
navigation.navigate('DialCall' as never, callingInfo as never);
|
|
423
|
+
}
|
|
424
|
+
//callingInfo != false then user have a calling.
|
|
425
|
+
```
|
|
426
|
+
|
|
397
427
|
- Other functions:
|
|
398
428
|
|
|
399
429
|
- Call with phone number (mobile phone or internal number):
|
|
@@ -404,6 +434,17 @@ extension Data {
|
|
|
404
434
|
phoneNumber: phone, //phone number
|
|
405
435
|
isVideo: false //allow video call: true/false
|
|
406
436
|
});
|
|
437
|
+
//we will return OmiStartCallStatus with:
|
|
438
|
+
- invalidUuid: uuid is invalid (we can not find on my page)
|
|
439
|
+
- invalidPhoneNumber: sip user is invalid.
|
|
440
|
+
- samePhoneNumber: Can not call same phone number.
|
|
441
|
+
- maxRetry: We try to refresh call but we can not start your call.
|
|
442
|
+
- permissionDenied: Check audio permission.
|
|
443
|
+
- couldNotFindEndpoint: Please login before make your call.
|
|
444
|
+
- accountRegisterFailed: We can not register your account.
|
|
445
|
+
- startCallFailed: We can not start you call.
|
|
446
|
+
- startCallSuccess: Start call successfully.
|
|
447
|
+
- haveAnotherCall: We can not start you call because you are joining another call.
|
|
407
448
|
```
|
|
408
449
|
|
|
409
450
|
- Call with UUID (only support with Api key):
|
|
@@ -414,6 +455,7 @@ extension Data {
|
|
|
414
455
|
usrUuid: uuid, //phone number
|
|
415
456
|
isVideo: false //allow video call: true/false
|
|
416
457
|
});
|
|
458
|
+
// Result is the same with startCall
|
|
417
459
|
```
|
|
418
460
|
|
|
419
461
|
- Accept a call:
|
|
@@ -505,7 +547,7 @@ extension Data {
|
|
|
505
547
|
}
|
|
506
548
|
```
|
|
507
549
|
|
|
508
|
-
- Logout:
|
|
550
|
+
- Logout: logout and remove all information.
|
|
509
551
|
|
|
510
552
|
```
|
|
511
553
|
import {logout} from 'omikit-plugin';
|
package/android/build.gradle
CHANGED
|
@@ -79,11 +79,14 @@ allprojects {
|
|
|
79
79
|
mavenCentral()
|
|
80
80
|
jcenter() // Warning: this repository is going to shut down soon
|
|
81
81
|
maven {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
url "https://gitlab.com/api/v4/projects/47675059/packages/maven"
|
|
83
|
+
credentials(HttpHeaderCredentials) {
|
|
84
|
+
name = "Private-Token"
|
|
85
|
+
value = "glpat-AzyyrvKz9_pjsgGW4xfp"
|
|
86
|
+
}
|
|
87
|
+
authentication {
|
|
88
|
+
header(HttpHeaderAuthentication)
|
|
89
|
+
}
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
}
|
|
@@ -99,7 +102,7 @@ dependencies {
|
|
|
99
102
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
100
103
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
101
104
|
|
|
102
|
-
api 'vn.vihat.omicall:omi-sdk:1.4.
|
|
105
|
+
api 'vn.vihat.omicall:omi-sdk:1.4.49'
|
|
103
106
|
// implementation fileTree(include: ['*.jar'], dir: 'libs')
|
|
104
107
|
// implementation files('OmiSDK.aar')
|
|
105
108
|
implementation 'androidx.appcompat:appcompat:1.5.0'
|
|
@@ -12,7 +12,6 @@ import android.provider.Settings
|
|
|
12
12
|
import android.util.Log
|
|
13
13
|
import androidx.annotation.RequiresApi
|
|
14
14
|
import androidx.core.app.ActivityCompat
|
|
15
|
-
import androidx.core.app.ActivityCompat.startActivityForResult
|
|
16
15
|
import androidx.core.content.ContextCompat
|
|
17
16
|
import com.facebook.react.ReactActivity
|
|
18
17
|
import com.facebook.react.bridge.*
|
|
@@ -28,6 +27,7 @@ import vn.vihat.omicall.omisdk.OmiClient
|
|
|
28
27
|
import vn.vihat.omicall.omisdk.OmiListener
|
|
29
28
|
import vn.vihat.omicall.omisdk.service.NotificationService
|
|
30
29
|
import vn.vihat.omicall.omisdk.utils.OmiSDKUtils
|
|
30
|
+
import vn.vihat.omicall.omisdk.utils.OmiStartCallStatus
|
|
31
31
|
import vn.vihat.omicall.omisdk.utils.SipServiceConstants
|
|
32
32
|
|
|
33
33
|
|
|
@@ -39,7 +39,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
39
39
|
return NAME
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
override fun incomingReceived(callerId: Int
|
|
42
|
+
override fun incomingReceived(callerId: Int?, phoneNumber: String?, isVideo: Boolean?) {
|
|
43
43
|
val map: WritableMap = WritableNativeMap()
|
|
44
44
|
map.putBoolean("isVideo", isVideo ?: true)
|
|
45
45
|
map.putString("callerNumber", phoneNumber)
|
|
@@ -54,6 +54,17 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
54
54
|
sendEvent(CALL_QUALITY, map)
|
|
55
55
|
}
|
|
56
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)
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
override fun onCallEnd(callInfo: MutableMap<String, Any?>, statusCode: Int) {
|
|
58
69
|
val call = callInfo as Map<*, *>
|
|
59
70
|
val map: WritableMap = WritableNativeMap()
|
|
@@ -114,11 +125,11 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
114
125
|
sendEvent(CALL_STATE_CHANGED, map)
|
|
115
126
|
}
|
|
116
127
|
|
|
117
|
-
override fun onRinging() {
|
|
128
|
+
override fun onRinging(callerId: Int, transactionId: String?) {
|
|
118
129
|
val map: WritableMap = WritableNativeMap()
|
|
119
130
|
map.putString("callerNumber", "")
|
|
120
131
|
map.putBoolean("isVideo", false)
|
|
121
|
-
map.putString("transactionId", "")
|
|
132
|
+
map.putString("transactionId", transactionId ?: "")
|
|
122
133
|
map.putInt("status", CallState.early.value)
|
|
123
134
|
sendEvent(CALL_STATE_CHANGED, map)
|
|
124
135
|
}
|
|
@@ -136,8 +147,6 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
136
147
|
private val accountListener = object : OmiAccountListener {
|
|
137
148
|
override fun onAccountStatus(online: Boolean) {
|
|
138
149
|
Log.d("aaa", "Account status $online")
|
|
139
|
-
// initResult?.success(online)
|
|
140
|
-
// initResult = null
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
|
|
@@ -146,7 +155,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
146
155
|
reactApplicationContext!!.addActivityEventListener(this)
|
|
147
156
|
Handler(Looper.getMainLooper()).post {
|
|
148
157
|
OmiClient(context = reactApplicationContext!!)
|
|
149
|
-
OmiClient.instance.
|
|
158
|
+
OmiClient.instance.addCallStateListener(this)
|
|
150
159
|
}
|
|
151
160
|
}
|
|
152
161
|
|
|
@@ -170,6 +179,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
170
179
|
Uri.parse("package:" + reactApplicationContext.packageName))
|
|
171
180
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
172
181
|
reactApplicationContext.startActivity(intent)
|
|
182
|
+
promise.resolve(true)
|
|
173
183
|
}
|
|
174
184
|
|
|
175
185
|
@ReactMethod
|
|
@@ -185,6 +195,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
185
195
|
val userImage = data.getString("userImage")
|
|
186
196
|
val userNameKey = data.getString("userNameKey")
|
|
187
197
|
val channelId = data.getString("channelId")
|
|
198
|
+
val audioNotificationDescription = data.getString("audioNotificationDescription")
|
|
199
|
+
val videoNotificationDescription = data.getString("videoNotificationDescription")
|
|
188
200
|
OmiClient.instance.configPushNotification(
|
|
189
201
|
notificationIcon = notificationIcon ?: "",
|
|
190
202
|
prefix = prefix ?: "Cuộc gọi tới từ: ",
|
|
@@ -194,9 +206,13 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
194
206
|
backImage = backImage ?: "ic_back",
|
|
195
207
|
userImage = userImage ?: "calling_face",
|
|
196
208
|
prefixMissedCallMessage = prefixMissedCallMessage ?: "Cuộc gọi nhỡ từ",
|
|
197
|
-
missedCallTitle = prefixMissedCallMessage ?: "Cuộc gọi nhỡ",
|
|
198
209
|
userNameKey = userNameKey ?: "extension",
|
|
199
210
|
channelId = channelId ?: "",
|
|
211
|
+
ringtone = null,
|
|
212
|
+
fullScreenUserImage = userImage ?: "calling_face",
|
|
213
|
+
showUserInfoInFullScreen = false,
|
|
214
|
+
audioNotificationDescription = audioNotificationDescription,
|
|
215
|
+
videoNotificationDescription = videoNotificationDescription
|
|
200
216
|
)
|
|
201
217
|
promise.resolve(true)
|
|
202
218
|
}
|
|
@@ -232,6 +248,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
232
248
|
val usrUuid = data.getString("usrUuid")
|
|
233
249
|
val apiKey = data.getString("apiKey")
|
|
234
250
|
val isVideo = data.getBoolean("isVideo")
|
|
251
|
+
val phone = data.getString("phone")
|
|
235
252
|
withContext(Dispatchers.Default) {
|
|
236
253
|
try {
|
|
237
254
|
if (usrName != null && usrUuid != null && apiKey != null) {
|
|
@@ -239,7 +256,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
239
256
|
apiKey = apiKey,
|
|
240
257
|
userName = usrName,
|
|
241
258
|
uuid = usrUuid,
|
|
242
|
-
|
|
259
|
+
phone = phone ?: "",
|
|
260
|
+
isVideo = isVideo,
|
|
243
261
|
)
|
|
244
262
|
}
|
|
245
263
|
} catch (_: Throwable) {
|
|
@@ -255,7 +273,17 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
255
273
|
@ReactMethod
|
|
256
274
|
fun getInitialCall(promise: Promise) {
|
|
257
275
|
currentActivity?.runOnUiThread {
|
|
258
|
-
|
|
276
|
+
val call = OmiClient.instance.getCurrentCallInfo()
|
|
277
|
+
if (call != null) {
|
|
278
|
+
val map: WritableMap = WritableNativeMap()
|
|
279
|
+
map.putString("callerNumber", call["callerNumber"] as String)
|
|
280
|
+
map.putInt("status", call["status"] as Int)
|
|
281
|
+
map.putBoolean("muted", call["muted"] as Boolean)
|
|
282
|
+
map.putBoolean("isVideo", call["isVideo"] as Boolean)
|
|
283
|
+
promise.resolve(map)
|
|
284
|
+
} else {
|
|
285
|
+
promise.resolve(false)
|
|
286
|
+
}
|
|
259
287
|
}
|
|
260
288
|
}
|
|
261
289
|
|
|
@@ -305,7 +333,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
305
333
|
)
|
|
306
334
|
if (audio == PackageManager.PERMISSION_GRANTED) {
|
|
307
335
|
mainScope.launch {
|
|
308
|
-
var callResult =
|
|
336
|
+
var callResult: OmiStartCallStatus? = null
|
|
309
337
|
withContext(Dispatchers.Default) {
|
|
310
338
|
try {
|
|
311
339
|
val uuid = data.getString("usrUuid") as String
|
|
@@ -335,8 +363,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
335
363
|
currentActivity?.runOnUiThread {
|
|
336
364
|
val call = OmiClient.instance.hangUp()
|
|
337
365
|
val map: WritableMap = WritableNativeMap()
|
|
338
|
-
val timeStartToAnswer = call
|
|
339
|
-
val timeEnd = call
|
|
366
|
+
val timeStartToAnswer = call?.get("time_start_to_answer") as Long?
|
|
367
|
+
val timeEnd = call?.get("time_end") as Long
|
|
340
368
|
map.putString("transaction_id", call["transaction_id"] as String?)
|
|
341
369
|
map.putString("direction", call["direction"] as String)
|
|
342
370
|
map.putString("source_number", call["source_number"] as String)
|
|
@@ -345,7 +373,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
345
373
|
map.putDouble("time_end", timeEnd.toDouble())
|
|
346
374
|
map.putString("sip_user", call["sip_user"] as String)
|
|
347
375
|
map.putString("disposition", call["disposition"] as String)
|
|
348
|
-
|
|
376
|
+
promise.resolve(map)
|
|
349
377
|
}
|
|
350
378
|
}
|
|
351
379
|
|
|
@@ -408,34 +436,6 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
408
436
|
}
|
|
409
437
|
}
|
|
410
438
|
|
|
411
|
-
@ReactMethod
|
|
412
|
-
fun omiInputs(promise: Promise) {
|
|
413
|
-
currentActivity?.runOnUiThread {
|
|
414
|
-
val inputs = OmiClient.instance.getAudioInputs()
|
|
415
|
-
val allAudios = inputs.map {
|
|
416
|
-
mapOf(
|
|
417
|
-
"name" to it.first,
|
|
418
|
-
"id" to it.second,
|
|
419
|
-
)
|
|
420
|
-
}.toTypedArray()
|
|
421
|
-
promise.resolve(allAudios)
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
@ReactMethod
|
|
426
|
-
fun omiOutputs(promise: Promise) {
|
|
427
|
-
currentActivity?.runOnUiThread {
|
|
428
|
-
val inputs = OmiClient.instance.getAudioOutputs()
|
|
429
|
-
val allAudios = inputs.map {
|
|
430
|
-
mapOf(
|
|
431
|
-
"name" to it.first,
|
|
432
|
-
"id" to it.second,
|
|
433
|
-
)
|
|
434
|
-
}.toTypedArray()
|
|
435
|
-
promise.resolve(allAudios)
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
439
|
@ReactMethod
|
|
440
440
|
fun logout(promise: Promise) {
|
|
441
441
|
mainScope.launch {
|
|
@@ -524,6 +524,37 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
+
@ReactMethod
|
|
528
|
+
fun getAudio(promise: Promise) {
|
|
529
|
+
val inputs = OmiClient.instance.getAudioOutputs()
|
|
530
|
+
val writeList = WritableNativeArray()
|
|
531
|
+
inputs.forEach {
|
|
532
|
+
val map = WritableNativeMap()
|
|
533
|
+
map.putString("name", it["name"] as String)
|
|
534
|
+
map.putInt("type", it["type"] as Int)
|
|
535
|
+
writeList.pushMap(map)
|
|
536
|
+
}
|
|
537
|
+
promise.resolve(writeList)
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
@ReactMethod
|
|
541
|
+
fun getCurrentAudio(promise: Promise) {
|
|
542
|
+
val currentAudio = OmiClient.instance.getCurrentAudio()
|
|
543
|
+
val map: WritableMap = WritableNativeMap()
|
|
544
|
+
map.putString("name", currentAudio["name"] as String)
|
|
545
|
+
map.putInt("type", currentAudio["type"] as Int)
|
|
546
|
+
val writeList = WritableNativeArray()
|
|
547
|
+
writeList.pushMap(map)
|
|
548
|
+
promise.resolve(writeList)
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
@ReactMethod
|
|
552
|
+
fun setAudio(data: ReadableMap, promise: Promise) {
|
|
553
|
+
val portType = data.getInt("portType")
|
|
554
|
+
OmiClient.instance.setAudio(portType)
|
|
555
|
+
promise.resolve(true)
|
|
556
|
+
}
|
|
557
|
+
|
|
527
558
|
companion object {
|
|
528
559
|
const val NAME = "OmikitPlugin"
|
|
529
560
|
fun onDestroy() {
|