omikit-plugin 2.4.0 → 3.0.0

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 (39) hide show
  1. package/README.md +62 -26
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +73 -42
  4. package/android/src/main/java/com/omikitplugin/constants/constant.kt +1 -0
  5. package/ios/CallProcess/CallManager.swift +151 -181
  6. package/ios/CallProcess/CallState.swift +1 -0
  7. package/ios/Constant/Constant.swift +1 -1
  8. package/ios/Library/OmikitPlugin.m +18 -0
  9. package/ios/Library/OmikitPlugin.swift +41 -15
  10. package/lib/commonjs/index.js +11 -0
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/commonjs/omi_call_state.js +1 -0
  13. package/lib/commonjs/omi_call_state.js.map +1 -1
  14. package/lib/commonjs/omi_start_call_status.js +21 -0
  15. package/lib/commonjs/omi_start_call_status.js.map +1 -0
  16. package/lib/commonjs/omikit.js +14 -6
  17. package/lib/commonjs/omikit.js.map +1 -1
  18. package/lib/module/index.js +1 -0
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/omi_call_state.js +1 -0
  21. package/lib/module/omi_call_state.js.map +1 -1
  22. package/lib/module/omi_start_call_status.js +14 -0
  23. package/lib/module/omi_start_call_status.js.map +1 -0
  24. package/lib/module/omikit.js +11 -6
  25. package/lib/module/omikit.js.map +1 -1
  26. package/lib/typescript/index.d.ts +1 -0
  27. package/lib/typescript/index.d.ts.map +1 -1
  28. package/lib/typescript/omi_call_state.d.ts +2 -1
  29. package/lib/typescript/omi_call_state.d.ts.map +1 -1
  30. package/lib/typescript/omi_start_call_status.d.ts +13 -0
  31. package/lib/typescript/omi_start_call_status.d.ts.map +1 -0
  32. package/lib/typescript/omikit.d.ts +6 -2
  33. package/lib/typescript/omikit.d.ts.map +1 -1
  34. package/omikit-plugin.podspec +1 -1
  35. package/package.json +1 -1
  36. package/src/index.tsx +1 -0
  37. package/src/omi_call_state.tsx +1 -0
  38. package/src/omi_start_call_status.tsx +12 -0
  39. package/src/omikit.tsx +15 -7
package/README.md CHANGED
@@ -96,21 +96,26 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
96
96
 
97
97
  ```
98
98
  //need request this permission
99
+ //need request this permission
99
100
  <uses-permission android:name="android.permission.INTERNET" />
100
- //add this lines inside <activity>
101
+ //add these lines inside <activity>
101
102
  <intent-filter>
102
103
  <action android:name="com.omicall.sdk.CallingActivity"/>
103
104
  <category android:name="android.intent.category.DEFAULT" />
104
105
  </intent-filter>
105
- //add this lines outside <activity>
106
+ //add these lines outside <activity>
106
107
  <receiver
107
- android:name="vn.vihat.omicall.omisdk.receiver.FirebaseMessageReceiver"
108
- android:exported="true"
109
- android:permission="com.google.android.c2dm.permission.SEND">
110
- <intent-filter>
111
- <action android:name="com.google.android.c2dm.intent.RECEIVE" />
112
- </intent-filter>
108
+ android:name="vn.vihat.omicall.omisdk.receiver.FirebaseMessageReceiver"
109
+ android:exported="true"
110
+ android:permission="com.google.android.c2dm.permission.SEND">
111
+ <intent-filter>
112
+ <action android:name="com.google.android.c2dm.intent.RECEIVE" />
113
+ </intent-filter>
113
114
  </receiver>
115
+ <service
116
+ android:name="vn.vihat.omicall.omisdk.service.NotificationService"
117
+ android:exported="false">
118
+ </service>
114
119
  ```
115
120
 
116
121
  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 +135,6 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
130
135
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
131
136
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
132
137
  <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
133
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
134
138
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
135
139
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
136
140
  <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
@@ -139,12 +143,14 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
139
143
  - Setup remote push notification: Only support Firebase for remote push notification.
140
144
 
141
145
  - 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 Fire Messaging to receive `fcm_token` (You can refer <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> to setup notification for React native)
146
+ - 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
147
 
144
148
  - 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
149
 
146
150
  #### iOS(Object-C):
147
151
 
152
+ - Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
153
+
148
154
  - Add variables in Appdelegate.h:
149
155
 
150
156
  ```
@@ -169,7 +175,7 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
169
175
  #import <OmiKit/OmiKit.h>
170
176
  #import <omicall_flutter_plugin/omicall_flutter_plugin-Swift.h>
171
177
 
172
- [OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX];
178
+ [OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX userNameKey:@"full_name" maxCall:2 callKitImage:@"call_image"];
173
179
  provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
174
180
  voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
175
181
  pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
@@ -234,7 +240,16 @@ if (@available(iOS 10.0, *)) {
234
240
 
235
241
  - 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
242
 
243
+ *** Important release note ***
244
+ ```
245
+ We support 2 environments. So you need set correct key in Appdelegate.
246
+ - KEY_OMI_APP_ENVIROMENT_SANDBOX support on debug mode
247
+ - KEY_OMI_APP_ENVIROMENT_PRODUCTION support on release mode
248
+ - Visit on web admin to select correct enviroment.
249
+ ```
250
+
237
251
  #### iOS(Swift):
252
+ - Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
238
253
 
239
254
  - Add variables in Appdelegate.swift:
240
255
 
@@ -251,7 +266,7 @@ var voipRegistry: PKPushRegistry?
251
266
  - Add these lines into `didFinishLaunchingWithOptions`:
252
267
 
253
268
  ```
254
- OmiClient.setEnviroment(KEY_OMI_APP_ENVIROMENT_SANDBOX)
269
+ OmiClient.setEnviroment(KEY_OMI_APP_ENVIROMENT_SANDBOX, userNameKey: "extension", maxCall: 1, callKitImage: "call_image")
255
270
  provider = CallKitProviderDelegate.init(callManager: OMISIPLib.sharedInstance().callManager)
256
271
  voipRegistry = PKPushRegistry.init(queue: .main)
257
272
  pushkitManager = PushKitManager.init(voipRegistry: voipRegistry)
@@ -290,6 +305,13 @@ extension Data {
290
305
  - 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
306
 
292
307
  - 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>
308
+ *** Important release note ***
309
+ ```
310
+ We support 2 environments. So you need set correct key in Appdelegate.
311
+ - KEY_OMI_APP_ENVIROMENT_SANDBOX support on debug mode
312
+ - KEY_OMI_APP_ENVIROMENT_PRODUCTION support on release mode
313
+ - Visit on web admin to select correct enviroment.
314
+ ```
293
315
 
294
316
 
295
317
  ## Implement
@@ -322,9 +344,9 @@ extension Data {
322
344
  usrUuid: usrUuid,
323
345
  fullName: fullName,
324
346
  apiKey: apiKey,
347
+ phone: phone,
325
348
  isVideo: isVideo,
326
349
  };
327
- console.log(loginInfo);
328
350
  const result = await initCallWithApiKey(loginInfo);
329
351
  //result is true then user login successfully.
330
352
  ```
@@ -362,22 +384,12 @@ extension Data {
362
384
  missedCallTitle: 'Cuộc gọi nhỡ', //config title for the missed call
363
385
  userNameKey: 'uuid', //we have 3 values: uuid, full_name, extension.
364
386
  channelId: 'com.channel.sample', //your notification channel id
387
+ audioNotificationDescription: '' //audio description
388
+ videoNotificationDescription: '' //video descriptipn
365
389
  });
366
390
  //incomingAcceptButtonImage, incomingDeclineButtonImage, backImage, userImage: Add these into `android/app/src/main/res/drawble`
367
391
  ```
368
392
 
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
393
  - 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
394
 
383
395
  ```
@@ -394,6 +406,18 @@ extension Data {
394
406
  });
395
407
  ```
396
408
 
409
+ - Get call when user open application at first time:
410
+
411
+ ```
412
+ import { getInitialCall } from 'omikit-plugin';
413
+
414
+ const callingInfo = await getInitialCall();
415
+ if (callingInfo !== false) {
416
+ navigation.navigate('DialCall' as never, callingInfo as never);
417
+ }
418
+ //callingInfo != false then user have a calling.
419
+ ```
420
+
397
421
  - Other functions:
398
422
 
399
423
  - Call with phone number (mobile phone or internal number):
@@ -404,6 +428,17 @@ extension Data {
404
428
  phoneNumber: phone, //phone number
405
429
  isVideo: false //allow video call: true/false
406
430
  });
431
+ //we will return OmiStartCallStatus with:
432
+ - invalidUuid: uuid is invalid (we can not find on my page)
433
+ - invalidPhoneNumber: sip user is invalid.
434
+ - samePhoneNumber: Can not call same phone number.
435
+ - maxRetry: We try to refresh call but we can not start your call.
436
+ - permissionDenied: Check audio permission.
437
+ - couldNotFindEndpoint: Please login before make your call.
438
+ - accountRegisterFailed: We can not register your account.
439
+ - startCallFailed: We can not start you call.
440
+ - startCallSuccess: Start call successfully.
441
+ - haveAnotherCall: We can not start you call because you are joining another call.
407
442
  ```
408
443
 
409
444
  - Call with UUID (only support with Api key):
@@ -414,6 +449,7 @@ extension Data {
414
449
  usrUuid: uuid, //phone number
415
450
  isVideo: false //allow video call: true/false
416
451
  });
452
+ // Result is the same with startCall
417
453
  ```
418
454
 
419
455
  - Accept a call:
@@ -505,7 +541,7 @@ extension Data {
505
541
  }
506
542
  ```
507
543
 
508
- - Logout: Can't receive call.
544
+ - Logout: logout and remove all information.
509
545
 
510
546
  ```
511
547
  import {logout} from 'omikit-plugin';
@@ -99,7 +99,7 @@ dependencies {
99
99
  implementation "com.facebook.react:react-native:+" // From node_modules
100
100
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
101
101
 
102
- api 'vn.vihat.omicall:omi-sdk:1.4.2'
102
+ api 'vn.vihat.omicall:omi-sdk:1.4.40'
103
103
  // implementation fileTree(include: ['*.jar'], dir: 'libs')
104
104
  // implementation files('OmiSDK.aar')
105
105
  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, phoneNumber: String?, isVideo: Boolean?) {
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.setListener(this)
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
- isVideo,
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
- promise.resolve(false)
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 = false
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["time_start_to_answer"] as Long?
339
- val timeEnd = call["time_end"] as Long
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
- sendEvent(CALL_STATE_CHANGED, map)
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() {
@@ -33,3 +33,4 @@ const val MUTED = "MUTED"
33
33
  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
+ const val AUDIO_CHANGE = "AUDIO_CHANGE"