omikit-plugin 3.2.65 → 3.2.67

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
@@ -1,44 +1,47 @@
1
- # OMICALL SDK FOR React-Native
1
+ # 📦 OMICALL SDK FOR React-Native
2
2
 
3
- The OmiKit exposes the <a href="https://www.npmjs.com/package/omikit-plugin">omikit-plugin</a>.
3
+ The OmiKit exposes the 📦 <a href="https://www.npmjs.com/package/omikit-plugin">omikit-plugin</a>.
4
4
 
5
5
  The most important part of the framework is :
6
6
 
7
- - Help to easy integrate with Omicall.
8
- - Easy custom Call UI/UX.
9
- - Optimize codec voip for you.
10
- - Full inteface to interactive with core function like sound/ringtone/codec.
7
+ - Help to easy integrate with Omicall.
8
+ - Easy custom Call UI/UX.
9
+ - Optimize codec voip for you.
10
+ - Full inteface to interactive with core function like sound/ringtone/codec.
11
11
 
12
- ### Status
12
+ ### 📝 Status
13
13
 
14
- Currently active maintenance and improve performance
14
+ Currently active maintenance and improve performance
15
+ <br>
15
16
 
16
- ### Running
17
+ ## 🛠️ Configuration
17
18
 
18
- Install via npm:
19
+ ### 🛠️ Install
20
+ <br>
21
+
22
+ ✅ Install via npm:
19
23
 
20
24
  ```ruby
21
25
  npm install omikit-plugin@latest
22
26
  ```
23
27
 
24
- Install via yarn:
25
-
28
+ Install via yarn:
26
29
  ```ruby
27
30
  yarn add omikit-plugin --latest
28
31
  ```
29
32
 
30
- ### Configuration
31
-
32
- #### Android:
33
+ #### 🛠️ Step 1: Config native file
33
34
 
35
+ ##### 🚀 Android:
36
+ 📌 **Config gradle file**
34
37
  - Add these settings in `build.gradle`:
35
38
 
36
- ```kotlin
37
- jcenter()
39
+ ```gradle
40
+ jcenter() // This func will replace soon
38
41
  maven {
39
42
  url "https://maven.pkg.github.com/omicall/OMICall-SDK"
40
43
  credentials {
41
- username = project.findProperty("OMI_USER") ?: ""
44
+ username = project.findProperty("OMI_USER") ?: "" // Please connect with developer OMI for get information
42
45
  password = project.findProperty("OMI_TOKEN") ?: ""
43
46
  }
44
47
  authentication {
@@ -47,6 +50,8 @@ maven {
47
50
  }
48
51
 
49
52
  ```
53
+
54
+
50
55
  ```kotlin
51
56
  // gradle.properties
52
57
  OMI_USER=omicall
@@ -56,6 +61,7 @@ OMI_TOKEN=${OMI_TOKEN} // connect with dev off OMI for get token
56
61
  ```kotlin
57
62
  // in dependencies
58
63
  classpath 'com.google.gms:google-services:4.3.13'
64
+ // You can choose the version of google-services to suit your project
59
65
  ```
60
66
 
61
67
  ```kotlin
@@ -104,34 +110,35 @@ apply plugin: 'com.google.gms.google-services'
104
110
 
105
111
  You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blob/main/example/android/app/build.gradle">android/app/build.gradle</a> to know more informations.
106
112
 
107
- - Update AndroidManifest.xml:
113
+ <br>
108
114
 
109
- ```kotlin
115
+ 📌 **Config AndroidManifest.xml file**
116
+
117
+
118
+
119
+ ```xml
110
120
  <manifest
111
- ......
112
121
  xmlns:tools="http://schemas.android.com/tools">
113
- ..... // your config
122
+ // ... your config
114
123
  <uses-feature android:name="android.hardware.telephony" android:required="false" />
115
124
  <uses-permission android:name="android.permission.INTERNET" />
116
125
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
117
126
  <uses-permission android:name="android.permission.WAKE_LOCK" />
118
127
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
119
- ..... // your config
128
+ // ... your config
120
129
 
121
130
  <application
122
131
  android:name=".MainApplication"
123
- ...... // your config
124
132
  android:alwaysRetainTaskState="true"
125
133
  android:largeHeap="true"
126
134
  android:exported="true"
127
135
  android:supportsRtl="true"
128
136
  android:allowBackup="false"
129
137
  android:enableOnBackInvokedCallback="true"
130
- ..... // your config
138
+ // ... your config
131
139
  >
132
140
  <activity
133
141
  android:name=".MainActivity"
134
- ..... // your config
135
142
  android:windowSoftInputMode="adjustResize"
136
143
  android:showOnLockScreen="true"
137
144
  android:launchMode="singleTask"
@@ -141,9 +148,9 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
141
148
  android:showWhenLocked="true"
142
149
  android:turnScreenOn="true"
143
150
  android:exported="true"
144
- ..... // your config
151
+ // ... your config
145
152
  >
146
- ..... // your config
153
+ // ... your config
147
154
  <intent-filter>
148
155
  <action android:name="android.intent.action.MAIN" />
149
156
  <category android:name="android.intent.category.LAUNCHER" />
@@ -155,9 +162,9 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
155
162
  android:host="incoming_call"
156
163
  android:scheme="omisdk" />
157
164
  </intent-filter>
158
- ..... // your config
165
+ // ... your config
159
166
  </activity>
160
- ..... // your config
167
+ // ... your config
161
168
  <receiver
162
169
  android:name="vn.vihat.omicall.omisdk.receiver.FirebaseMessageReceiver"
163
170
  android:exported="true"
@@ -173,17 +180,19 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
173
180
  android:enabled="true"
174
181
  android:exported="false">
175
182
  </service>
176
- ..... // your config
183
+ // ... your config
177
184
  </application>
178
185
  </manifest>
179
186
  ```
180
187
 
181
- ##### In file MainActivity:
182
- # For React Native < 0.74
188
+ <br>
189
+
190
+ 📌 **Config MainActivity file**
191
+ ### ✅ For React Native < 0.74
183
192
 
184
193
  ```java
185
194
  public class MainActivity extends ReactActivity {
186
- ..... // your config
195
+ // your config ...
187
196
 
188
197
 
189
198
  @Override
@@ -208,16 +217,17 @@ public class MainActivity extends ReactActivity {
208
217
  if (intent != null) {
209
218
  OmikitPluginModule.Companion.onGetIntentFromNotification(reactApplicationContext, intent, this);
210
219
  }
211
- ..... // your config
220
+ // your config ...
212
221
  }
213
222
  }
214
223
  ```
215
224
 
216
- # For React Native > 0.74
225
+ ### For React Native > 0.74
226
+
217
227
 
218
228
  ```kotlin
219
229
  class MainActivity : ReactActivity() {
220
- ..... // your config
230
+ // your config ....
221
231
  private var reactApplicationContext: ReactApplicationContext? = null
222
232
  override fun onCreate(savedInstanceState: Bundle?) {
223
233
  super.onCreate(savedInstanceState)
@@ -261,27 +271,31 @@ class MainActivity : ReactActivity() {
261
271
  } ?: Log.e("MainActivity", "ReactApplicationContext has not been initialized in onResume.")
262
272
  }
263
273
 
264
- ..... // your config
274
+ // your config ....
265
275
  }
266
276
  ```
267
277
 
268
278
 
269
- - Setup remote push notification: Only support Firebase for remote push notification.
279
+ - Setup remote push notification: Only support Firebase for remote push notification.
270
280
 
271
- - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
272
- - 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)
281
+ - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
282
+ - 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)
273
283
 
274
- - 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>
284
+ - 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>
275
285
 
276
- ## Config for IOS
286
+ <br>
277
287
 
278
- #### iOS(Object-C):
288
+ *Now let's continue configuring iOS, let's go 🚀*
279
289
 
280
- - Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
290
+ ##### 🚀 Config for IOS
281
291
 
282
- - Add variables in **Appdelegate.h** for **Old Architecture**:
292
+ ##### 📌 iOS(Object-C):
283
293
 
284
- ```objective-c
294
+ - ✅ Assets: Add `call_image` into assets folder to update callkit image. We only support png style. *(This will help show your application icon on iOS CallKit when a call comes in)*
295
+
296
+ - ✅ Add variables in **Appdelegate.h** for **Old Architecture**:
297
+
298
+ ```objc
285
299
  #import <UIKit/UIKit.h>
286
300
  #import <UserNotifications/UserNotifications.h>
287
301
  #import <OmiKit/OmiKit-umbrella.h>
@@ -297,9 +311,9 @@ class MainActivity : ReactActivity() {
297
311
  @end
298
312
  ```
299
313
 
300
- - Add variables in **Appdelegate.h** for **New Architecture**:
314
+ - Add variables in **Appdelegate.h** for **New Architecture**:
301
315
 
302
- ```objective-c
316
+ ```objc
303
317
  #import <UIKit/UIKit.h>
304
318
  #import <UserNotifications/UserNotifications.h>
305
319
  #import <OmiKit/OmiKit-umbrella.h>
@@ -316,11 +330,12 @@ class MainActivity : ReactActivity() {
316
330
 
317
331
  ```
318
332
 
319
- - Edit AppDelegate.m:
333
+ - Update AppDelegate.m:
320
334
 
321
- ```objective-c
335
+ ```objc
322
336
  #import <OmiKit/OmiKit.h>
323
337
 
338
+
324
339
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
325
340
  {
326
341
 
@@ -366,9 +381,10 @@ class MainActivity : ReactActivity() {
366
381
  }
367
382
  }
368
383
  ```
369
- - Tips: Error Use of undeclared identifier 'OmikitNotification' at file `AppDelegate.m`, please import this line below
370
384
 
371
- ```swift
385
+ - 📝 Tips: Error Use of undeclared identifier 'OmikitNotification' at file `AppDelegate.m`, please import this line below
386
+
387
+ ```objc
372
388
  #if __has_include("OmikitNotification.h")
373
389
  #import "OmikitNotification.h"
374
390
  #elif __has_include(<OmikitPlugin/OmikitPlugin-Swift.h>)
@@ -380,7 +396,7 @@ class MainActivity : ReactActivity() {
380
396
  ```
381
397
  - Add these lines into `Info.plist`:
382
398
 
383
- ```swift
399
+ ```xml
384
400
  <key>NSMicrophoneUsageDescription</key>
385
401
  <string>Need microphone access for make Call</string>
386
402
  //If you implement video call
@@ -388,7 +404,7 @@ class MainActivity : ReactActivity() {
388
404
  <string>Need camera access for video call functions</string>
389
405
  ```
390
406
 
391
- - Save token for `OmiClient`: if You added `Cloud Messaging` in your project so you don't need add these lines.
407
+ - 💡 Save token for `OmiClient`: if You added `Cloud Messaging` in your project so you don't need add these lines.
392
408
 
393
409
  ```swift
394
410
  - (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)devToken
@@ -409,16 +425,14 @@ class MainActivity : ReactActivity() {
409
425
 
410
426
  ```
411
427
 
412
- **_ Only use under lines when added `Cloud Messaging` plugin in your project _**
428
+ **✨ Only use under lines when added `Cloud Messaging` plugin in your project**
413
429
 
414
- - Setup push notification: We only support Firebase for push notification.
430
+ - Setup push notification: We only support Firebase for push notification.
431
+ - ✅ Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
432
+ - ✅ 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)
433
+ - ✅ 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>
415
434
 
416
- - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
417
- - 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)
418
-
419
- - 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>
420
-
421
- **_ Important release note _**
435
+ **✨Important release note**
422
436
 
423
437
  ```
424
438
  We support 2 environments. So you need set correct key in Appdelegate.
@@ -427,11 +441,15 @@ We support 2 environments. So you need set correct key in Appdelegate.
427
441
  - Visit on web admin to select correct enviroment.
428
442
  ```
429
443
 
430
- \*Note: At Tab Build Setting off Target Project, you need set: **_Enable Modules (C and Objective C)_** : YES\*
444
+ *📝Note: At Tab Build Setting off Target Project, you need set: **_Enable Modules (C and Objective C)_** : YES*
445
+
446
+ #### ❌ Currently, OMICALL does not support React Native new architect.
431
447
 
432
- #### Currently, OMICALL does not support React Native new architect.
433
- Config turn Off for new architect
434
- For iOS
448
+ 📌 Config turn Off for new architect
449
+
450
+ <br>
451
+
452
+ ✅ For iOS
435
453
  ```Ruby
436
454
  use_react_native!(
437
455
  :path => config[:reactNativePath],
@@ -440,17 +458,18 @@ use_react_native!(
440
458
  )
441
459
  ```
442
460
 
443
- For Android
444
- Open file android/gradle.properties and add line below:
461
+ For Android
462
+
463
+ - Open file **_android/gradle.properties_** and add line below:
445
464
  ```kotlin
446
- # Tắt New Architecture
465
+ # Turn off New Architecture
447
466
  newArchEnabled=false
448
467
  ```
449
- #### iOS(Swift):
468
+ #### 📌 iOS(Swift):
450
469
 
451
- - Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
470
+ 📝 Notes: The configurations are similar to those for object C above, with only a slight difference in the syntax of the functions
452
471
 
453
- - Add variables in Appdelegate.swift:
472
+ - Add variables in Appdelegate.swift:
454
473
 
455
474
  ```swift
456
475
  import OmiKit
@@ -462,7 +481,7 @@ var provider: CallKitProviderDelegate?
462
481
  var voipRegistry: PKPushRegistry?
463
482
  ```
464
483
 
465
- - Add these lines into `didFinishLaunchingWithOptions`:
484
+ - Add these lines into `didFinishLaunchingWithOptions`:
466
485
 
467
486
  ```swift
468
487
  OmiClient.setEnviroment(KEY_OMI_APP_ENVIROMENT_SANDBOX, userNameKey: "extension", maxCall: 1, callKitImage: "call_image")
@@ -471,16 +490,16 @@ voipRegistry = PKPushRegistry.init(queue: .main)
471
490
  pushkitManager = PushKitManager.init(voipRegistry: voipRegistry)
472
491
  ```
473
492
 
474
- - Add these lines into `Info.plist`:
493
+ - Add these lines into `Info.plist`:
475
494
 
476
- ```swift
495
+ ```xml
477
496
  <key>NSCameraUsageDescription</key>
478
497
  <string>Need camera access for video call functions</string>
479
498
  <key>NSMicrophoneUsageDescription</key>
480
499
  <string>Need microphone access for make Call</string>
481
500
  ```
482
501
 
483
- - Save token for `OmiClient`: if you added `firebase_messaging` in your project so you don't need add these lines.
502
+ - Save token for `OmiClient`: if you added `firebase_messaging` in your project so you don't need add these lines.
484
503
 
485
504
  ```swift
486
505
  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
@@ -496,15 +515,15 @@ extension Data {
496
515
  }
497
516
  ```
498
517
 
499
- **_ Only use under lines when added `Cloud Messaging` plugin in your project _**
500
-
501
- - Setup push notification: We only support Firebase for push notification.
518
+ **✨ Only use under lines when added `Cloud Messaging` plugin in your project**
502
519
 
503
- - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
504
- - 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)
520
+ - Setup push notification: We only support Firebase for push notification.
521
+ - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
522
+ - ✅ 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)
523
+ - ✅ 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>
524
+ -
505
525
 
506
- - 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>
507
- **_ Important release note _**
526
+ **❌ Important release note**
508
527
 
509
528
  ```
510
529
  We support 2 environments. So you need set correct key in Appdelegate.
@@ -513,13 +532,13 @@ We support 2 environments. So you need set correct key in Appdelegate.
513
532
  - Visit on web admin to select correct enviroment.
514
533
  ```
515
534
 
516
- ## Implement
535
+ ## 🛠️ Step 2: Integrate into React Native code
517
536
 
518
- ### Request permission
537
+ ### 🚀 Request permission
519
538
 
520
- We need you request permission about call before make call:
539
+ **📌 We need you request permission about call before make call:**
521
540
 
522
- - You can use <a href="https://github.com/zoontek/react-native-permissions">react-native-permissions</a> to do this
541
+ - You can use <a href="https://github.com/zoontek/react-native-permissions">react-native-permissions</a> to do this
523
542
 
524
543
  ```
525
544
  -Android:
@@ -533,131 +552,174 @@ We need you request permission about call before make call:
533
552
 
534
553
  ```
535
554
 
536
- - Set up <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> plugin:
555
+ - Set up <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> plugin:
537
556
 
538
557
  ```
539
558
  //if you use only on Android. you only implement for Android.
540
559
  //because we use APNS to push notification on iOS so you don't need add Firebase for iOS.
541
560
  //But you can use firebase-messaging to get APNS token for iOS.
542
561
  ```
562
+ #### 🚀 OMIKIT-Plugin functions 🚀
563
+ <br>
543
564
 
544
- - Important function.
565
+ 📌 **startServices()**
545
566
 
546
- - Start Serivce: OmiKit need start services and register some events.
567
+ Description:
547
568
 
548
- ```javascript
549
- //Call in the root widget
550
- import { startServices } from 'omikit-plugin';
569
+ The `startServices()` function is used to initialize necessary services in `omikit-plugin`.
570
+ It should only be called once in the root file of your application.
551
571
 
552
- startServices();
553
- ```
572
+ - Usage:
573
+ ```javascript
574
+ // Import startServices from omikit-plugin
575
+ import { startServices } from 'omikit-plugin';
554
576
 
555
- - 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>
577
+ // Call startServices() to initialize the required services
578
+ startServices();
579
+ ```
580
+ - 📝 Notes:<br>
581
+ • Do not call this function multiple times; it should be called only once when the application starts. <br>
582
+ • Ensure that `omikit-plugin` is installed before using this function.
556
583
 
557
- - 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).
558
- Please contact for my sale:
559
- In This step, we need partner provide me fcmToken of firebase Message.
584
+ *Add the following code to the root file of your application, such as `App.js` or `index.js`*
560
585
 
561
- ```javascript
562
- import { initCallWithApiKey } from 'omikit-plugin';
563
- import messaging from '@react-native-firebase/messaging';
586
+ 📌 **initCallWithApiKey()**
564
587
 
565
- let token: String
566
- if(Platform.OS == "ios"){
567
- token = await messaging.getAPNSToken()
568
- } else {
569
- token = await messaging.getToken()
570
- }
588
+ 📝 Notes: The information below is taken from the API, you should connect with our Technical team for support
571
589
 
572
- const loginInfo = {
573
- usrUuid: usrUuid,
574
- fullName: fullName,
575
- apiKey: apiKey,
576
- phone: phone,
577
- fcmToken: token, //with android is fcm_token and ios is APNS token
578
- isVideo: isVideo,
579
- projectId: projectId // firebase project id off your
580
- };
581
- const result = await initCallWithApiKey(loginInfo);
582
- //result is true then user login successfully.
583
- ```
590
+ Description: <br>
591
+ - The `initCallWithApiKey()` function is usually used for your client, who only has a certain function, calling a fixed number. For example, you can only call your hotline number
592
+
593
+ ```javascript
594
+ import { initCallWithApiKey } from 'omikit-plugin';
595
+ import messaging from '@react-native-firebase/messaging';
596
+
597
+ let token: String;
598
+
599
+ // Retrieve the appropriate push notification token based on the platform
600
+ if (Platform.OS === "ios") {
601
+ token = await messaging.getAPNSToken(); // Get APNS token for iOS
602
+ } else {
603
+ token = await messaging.getToken(); // Get FCM token for Android
604
+ }
605
+
606
+ // Define the login information required for call initialization
607
+ const loginInfo = {
608
+ usrUuid: usrUuid, // Unique user identifier
609
+ fullName: fullName, // User's full name
610
+ apiKey: apiKey, // API key for authentication
611
+ phone: phone, // User's phone number
612
+ fcmToken: token, // FCM token for Android, APNS token for iOS
613
+ isVideo: isVideo, // Determines if video calls are enabled
614
+ projectId: projectId // Firebase project ID
615
+ };
616
+
617
+ // Initialize call functionality using the provided API key
618
+ const result = await initCallWithApiKey(loginInfo);
584
619
 
585
- - Create OmiKit: OmiKit need userName, password, realm, fcmToken to init environment(All information in innit is required). ViHAT Group will provide information for you.
586
- This function is used when you want to call any telecommunication number, calling back and forth between internal groups.
587
- Please contact for my sale:
620
+ // If result is true, the user has successfully logged in.
621
+ ```
588
622
 
623
+ 📌 **initCallWithUserPassword()**
624
+
625
+ 📝 Notes: The information below is taken from the API, you should connect with our Technical team for support
626
+
627
+ ✅ Description: <br>
628
+ - The `initCallWithUserPassword()` function is for employees. They can call any telecommunications number allowed in your business on the OMI system.
629
+
589
630
  ```javascript
590
- import { initCallWithUserPassword } from 'omikit-plugin';
591
- import messaging from '@react-native-firebase/messaging';
592
-
593
- let token: String
594
- if(Platform.OS == "ios"){
595
- token = await messaging.getAPNSToken()
596
- } else {
597
- token = await messaging.getToken()
598
- }
631
+ import { initCallWithUserPassword } from 'omikit-plugin';
632
+ import messaging from '@react-native-firebase/messaging';
599
633
 
600
- const loginInfo = {
601
- userName: userName, //string
602
- password: password, //string
603
- realm: realm, //string
604
- isVideo: isVideo, //boolean: true/false
605
- fcmToken: token, //with android is fcm_token and ios is APNS token,
606
- projectId: projectId // firebase project id off your
607
- };
608
- const result = await initCallWithUserPassword(loginInfo);
609
- //result is true then user login successfully.
634
+ let token: String;
635
+
636
+ // Retrieve the appropriate push notification token based on the platform
637
+ if (Platform.OS === "ios") {
638
+ token = await messaging.getAPNSToken(); // Get APNS token for iOS
639
+ } else {
640
+ token = await messaging.getToken(); // Get FCM token for Android
641
+ }
642
+
643
+ // Define the login information required for call initialization
644
+ const loginInfo = {
645
+ userName: userName, // User's SIP username (string)
646
+ password: password, // User's SIP password (string)
647
+ realm: realm, // SIP server domain (string)
648
+ isVideo: isVideo, // Enables or disables video calls (boolean: true/false)
649
+ fcmToken: token, // FCM token for Android, APNS token for iOS
650
+ projectId: projectId // Firebase project ID
651
+ };
652
+
653
+ // Initialize call functionality using username and password authentication
654
+ const result = await initCallWithUserPassword(loginInfo);
655
+ // If result is true, the user has successfully logged in.
610
656
  ```
611
657
 
612
- - Config push notification:
658
+ 📌 **configPushNotification()**
659
+
660
+ ✅ Description: Config push notification: func is used to configure the incoming call popup UI on Android and the representative name for iOS
613
661
 
614
662
  ```javascript
615
- import { configPushNotification } from 'omikit-plugin';
616
-
617
- configPushNotification({
618
- notificationIcon : "calling_face", //notification icon on Android
619
- prefix : "Cuộc gọi tới từ: ",
620
- incomingBackgroundColor : "#FFFFFFFF",
621
- incomingAcceptButtonImage : "join_call", //image name
622
- incomingDeclineButtonImage : "hangup", //image name
623
- backImage : "ic_back", //image name: icon of back button
624
- userImage : "calling_face", //image name: icon of user default
625
- prefixMissedCallMessage: 'Cuộc gọi nhỡ từ', //config prefix message for the missed call
626
- missedCallTitle: 'Cuộc gọi nhỡ', //config title for the missed call
627
- userNameKey: 'uuid', //we have 3 values: uuid, full_name, extension.
628
- channelId: 'com.channel.sample', //your notification channel id
629
- audioNotificationDescription: '' //audio description
630
- videoNotificationDescription: '' //video descriptipn,
631
- representName: '' // Pass down the representative name if you want all incoming calls on the customer app to display only 1 unique name of your business
632
- });
633
- //incomingAcceptButtonImage, incomingDeclineButtonImage, backImage, userImage: Add these into `android/app/src/main/res/drawble`
663
+ import { configPushNotification } from 'omikit-plugin';
664
+
665
+ // Configure push notifications for incoming calls
666
+ configPushNotification({
667
+ notificationIcon: "calling_face", // Notification icon for Android (located in drawable folder)
668
+ prefix: "Cuộc gọi tới từ: ", // Prefix for incoming call notifications
669
+ incomingBackgroundColor: "#FFFFFFFF", // Background color for incoming call screen
670
+ incomingAcceptButtonImage: "join_call", // Image for the accept call button
671
+ incomingDeclineButtonImage: "hangup", // Image for the decline call button
672
+ backImage: "ic_back", // Image for the back button
673
+ userImage: "calling_face", // Default user image for incoming calls
674
+ prefixMissedCallMessage: "Cuộc gọi nhỡ từ", // Prefix message for missed call notifications
675
+ missedCallTitle: "Cuộc gọi nhỡ", // Title for missed call notifications
676
+ userNameKey: "uuid", // User identification key: options are "uuid", "full_name", or "extension"
677
+ channelId: "com.channel.sample", // Custom notification channel ID for Android
678
+ audioNotificationDescription: "", // Description for audio call notifications
679
+ videoNotificationDescription: "", // Description for video call notifications
680
+ representName: "" // Representative name to display for all incoming calls (e.g., business name)
681
+ });
682
+
683
+ // Note: Ensure that the following images are added to `android/app/src/main/res/drawable`:
684
+ // - incomingAcceptButtonImage (join_call)
685
+ // - incomingDeclineButtonImage (hangup)
686
+ // - backImage (ic_back)
687
+ // - userImage (calling_face)
634
688
  ```
635
689
 
636
- - Get call when user open application at first time:
690
+ 📌 **getInitialCall()**
637
691
 
638
- ```
639
- import { getInitialCall } from 'omikit-plugin';
692
+ ✅ Description: Get call when user open application at first time
640
693
 
641
- const callingInfo = await getInitialCall();
642
- if (callingInfo !== false) {
643
- navigation.navigate('DialCall' as never, callingInfo as never);
644
- }
645
- //callingInfo != false then user have a calling.
694
+ ```javascript
695
+ import { getInitialCall } from 'omikit-plugin';
696
+
697
+ // Check if there is an ongoing call when the app initializes
698
+ const callingInfo = await getInitialCall();
699
+
700
+ if (callingInfo !== false) {
701
+ // If there is an active call, navigate to the call screen
702
+ navigation.navigate('DialCall' as never, callingInfo as never);
703
+ }
704
+
705
+ // If callingInfo is not false, it means the user has an ongoing call.
646
706
  ```
647
707
 
648
- - Other functions:
708
+ 📌 **startCall()**
649
709
 
650
- - Call with phone number (mobile phone or internal number):
710
+ Description: Used to initiate a call to a random number, telecommunication number, hotline or internal number
651
711
 
652
712
  ```javascript
653
- import {startCall} from 'omikit-plugin';
654
- const result = await startCall({
655
- phoneNumber: phone, //phone number
656
- isVideo: false //allow video call: true/false
657
- });
713
+ import { startCall } from 'omikit-plugin';
714
+
715
+ // Start a call with the given phone number
716
+ const result = await startCall({
717
+ phoneNumber: phone, // The phone number to call
718
+ isVideo: false // Set to true for a video call, false for an audio call
719
+ });
658
720
  ```
659
721
 
660
- - The result will be in the form of object:
722
+ The result returned by `startCall()` is an object with the following structure:
661
723
 
662
724
  ```javascript
663
725
  result = {
@@ -667,47 +729,72 @@ We need you request permission about call before make call:
667
729
  }
668
730
  ```
669
731
 
670
- - Describe in detail the results when startCall returns:
732
+ 📝 Detailed Description of Possible Results
671
733
 
672
- ```javascript
673
- + message="INVALID_UUID" (status = 0) : uid is invalid (we can not find on my page).
674
- + message="INVALID_PHONE_NUMBER" (status = 1) : sip user is invalid.
675
- + message="SAME_PHONE_NUMBER_WITH_PHONE_REGISTER" (status = 2) : Can not call same phone number.
676
- + message="MAX_RETRY" (status = 3) : call timeout exceeded, please try again later.
677
- + message="PERMISSION_DENIED" (status = 4) : The user has not granted MIC or audio permissions.
678
- + message="COULD_NOT_FIND_END_POINT" (status = 5) : Please login before make your call.
679
- + message="REGISTER_ACCOUNT_FAIL" (status = 6) : Can't log in to OMI( maybe wrong login information).
680
- + message="START_CALL_FAIL" (status = 7) : Call failed, please try again
681
- + message="HAVE_ANOTHER_CALL" (status = 9) : There is another call in progress, please wait for that call to end
682
- + message="START_CALL_SUCCESS" (status = 8) : START CALL SUCCESSFULLY.
734
+ | **Message** | **Status** | **Description** |
735
+ |-------------------------------------------|------------|-------------------------------------------------------------------------|
736
+ | `"INVALID_UUID"` | 0 | uid is invalid (we can not find on my page) |
737
+ | `"INVALID_PHONE_NUMBER"` | 1 | sip user is invalid |
738
+ | `"SAME_PHONE_NUMBER_WITH_PHONE_REGISTER"` | 2 | Cannot call same phone number |
739
+ | `"MAX_RETRY"` | 3 | Call timeout exceeded, please try again later |
740
+ | `"PERMISSION_DENIED"` | 4 | The user has not granted MIC or audio permissions |
741
+ | `"COULD_NOT_FIND_END_POINT"` | 5 | Please login before making your call |
742
+ | `"REGISTER_ACCOUNT_FAIL"` | 6 | Can't log in to OMI (maybe wrong login information) |
743
+ | `"START_CALL_FAIL"` | 7 | Call failed, please try again |
744
+ | `"HAVE_ANOTHER_CALL"` | 9 | There is another call in progress; please wait for that call to end |
745
+ | `"START_CALL_SUCCESS"` | 8 | START CALL SUCCESSFULLY |
683
746
 
684
- ```
747
+ <br>
685
748
 
686
- - Call with UUID (only support with Api key):
749
+ 📌 **startCallWithUuid()**
687
750
 
688
- ```javascript
689
- import {startCallWithUuid} from 'omikit-plugin';
690
- const result = await startCallWithUuid({
691
- usrUuid: uuid, //phone number
692
- isVideo: false //allow video call: true/false
693
- });
694
- // Result is the same with startCall
695
- ```
751
+ ✅ Description: Call with UUID (only support with Api key):
696
752
 
697
- - Accept a call:
753
+ ```javascript
754
+ import { startCallWithUuid } from 'omikit-plugin';
698
755
 
699
- ```javascript
700
- import {joinCall} from 'omikit-plugin';
756
+ // Initiate a call using the user's UUID. This function works similarly to `startCall()`.
757
+ const result = await startCallWithUuid({
758
+ usrUuid: uuid, // The user's UUID (unique identifier)
759
+ isVideo: false // Set to true for a video call, false for an audio call
760
+ });
701
761
 
702
- await joinCall();
703
- ```
762
+ // The result returned has the same structure as that from `startCall()`.
763
+ ```
704
764
 
705
- Note: When calling `joinCall`, sdk will check permission of microphone and camera. If have any permission denied, sdk will send a event `onRequestPermissionAndroid` with list permission you need to request. You need to request permission before calling `joinCall` again.
765
+ <br>
706
766
 
707
- - End a call: We will push a event `endCall` for you.
767
+ 📌 **joinCall()**
708
768
 
709
- ```javascript
710
- import {endCall} from 'omikit-plugin';
769
+ ✅ Description: Used to join (pick up) any incoming call
770
+
771
+ ```javascript
772
+ import {joinCall} from 'omikit-plugin';
773
+
774
+ await joinCall();
775
+ ```
776
+
777
+ 📝 Note: When calling `joinCall`, sdk will check permission of microphone and camera. If have any permission denied, sdk will send a event `onRequestPermissionAndroid` with list permission you need to request. You need to request permission before calling `joinCall` again.
778
+
779
+
780
+ 📌 **transferCall()**
781
+
782
+ ✅ Description: Used to forward the current ongoing call to any employee in your business
783
+
784
+ ```javascript
785
+ import {transferCall} from 'omikit-plugin';
786
+
787
+ transferCall({
788
+ phoneNumber: 102 // employee's internal number
789
+ })
790
+ ```
791
+
792
+ 📌 **endCall()**
793
+
794
+ ✅ Description: We will push a event `endCall` for you.
795
+
796
+ ```javascript
797
+ import {endCall} from 'omikit-plugin';
711
798
 
712
799
  const value = await endCall();
713
800
  //value is call information
@@ -722,184 +809,255 @@ We need you request permission about call before make call:
722
809
  "sip_user":111,
723
810
  "disposition":"answered"
724
811
  }
725
- ```
812
+ ```
813
+
814
+ 📌 **toggleMute()**
726
815
 
727
- - Toggle the audio: On/off audio a call
816
+ ✅ Description: Toggle the audio, On/off audio a call
728
817
 
729
- ```javascript
730
- import {toggleMute} from 'omikit-plugin';
818
+ ```javascript
819
+ import {toggleMute} from 'omikit-plugin';
731
820
 
732
- toggleMute();
733
- ```
821
+ toggleMute();
822
+ ```
734
823
 
735
- - Toggle the speaker: On/off the phone speaker
824
+ 📌 **toggleSpeaker()**
736
825
 
737
- ```javascript
738
- import {toggleSpeaker} from 'omikit-plugin';
826
+ ✅ Description: Toggle the speaker, On/off the phone speaker
739
827
 
740
- toggleSpeaker();
741
- ```
742
- - Toggle the hold: hold current call
828
+ ```javascript
829
+ import {toggleSpeaker} from 'omikit-plugin';
743
830
 
744
- ```javascript
745
- import {toggleHold} from 'omikit-plugin';
831
+ toggleSpeaker();
832
+ ```
746
833
 
747
- toggleHold();
748
- ```
834
+ 📌 **toggleHold()**
749
835
 
750
- - Send character: We only support `1 to 9` and `* #`.
836
+ Description: hold current call
751
837
 
752
- ```javascript
838
+ ```javascript
839
+ import {toggleHold} from 'omikit-plugin';
840
+
841
+ toggleHold();
842
+ ```
843
+
844
+ 📌 **sendDTMF()**
845
+
846
+ ✅ Description: Send character: We only support `1 to 9` and `* #`.
847
+
848
+ ```javascript
849
+ // FUNC IS USED when the user wants key interaction during a call. For example, press key 1, 2, 3.. to move to group
753
850
  import {sendDTMF} from 'omikit-plugin';
754
851
 
755
852
  sendDTMF({
756
853
  character: text,
757
854
  });
758
- ```
855
+ ```
856
+
857
+ 📌 **getCurrentUser()**
759
858
 
760
- - Get current user information:
761
- ```javascript
859
+ Description: Retrieves the current user's information.
860
+
861
+ ```javascript
862
+ import {getCurrentUser} from 'omikit-plugin';
762
863
  final user = await getCurrentUser();
763
- Output Sample:
764
- {
765
- "extension": "111",
766
- "full_name": "chau1",
767
- "avatar_url": "",
768
- "uuid": "122aaa"
769
- }
770
- ```
771
- - Get guest user information:
772
- ```javascript
864
+ ```
865
+
866
+ ✨ Output Sample:
867
+
868
+ ```javascript
869
+ {
870
+ "extension": "111",
871
+ "full_name": "chau1",
872
+ "avatar_url": "",
873
+ "uuid": "122aaa"
874
+ }
875
+ ```
876
+
877
+ 📌 **getGuestUser()**
878
+
879
+ ✅ Description: Get guest user information:
880
+
881
+ ```javascript
882
+ import {getGuestUser} from 'omikit-plugin';
773
883
  final user = await getGuestUser();
774
- Output Sample:
775
- {
776
- "extension": "111",
777
- "full_name": "chau1",
778
- "avatar_url": "",
779
- "uuid": "122aaa"
780
- }
781
- ```
782
- - Get user information from sip:
884
+ ```
783
885
 
784
- ```javascript
785
- final user = await getUserInfo("111");
786
- Output Sample:
787
- {
788
- "extension": "111",
789
- "full_name": "chau1",
790
- "avatar_url": "",
791
- "uuid": "122aaa"
792
- }
793
- ```
794
- - endCall: End a completed call (including rejecting a call).
886
+ ✨ Output Sample:
795
887
 
796
- ```javascript
797
- import {endCall} from 'omikit-plugin';
888
+ ```javascript
889
+ {
890
+ "extension": "111",
891
+ "full_name": "chau1",
892
+ "avatar_url": "",
893
+ "uuid": "122aaa"
894
+ }
895
+ ```
896
+
897
+ 📌 **ggetUserInfo()**
798
898
 
899
+ ✅ Description: Get user information from internal number
900
+
901
+ ```javascript
902
+ import {getUserInfo} from 'omikit-plugin';
903
+ final user = await ggetUserInfo("111");
904
+ ```
905
+
906
+ ✨ Output Sample:
907
+
908
+ ```javascript
909
+ {
910
+ "extension": "111",
911
+ "full_name": "chau1",
912
+ "avatar_url": "",
913
+ "uuid": "122aaa"
914
+ }
915
+ ```
916
+
917
+ 📌 **endCall()**
918
+
919
+ ✅ Description: End a completed call (including rejecting a call).
920
+
921
+ ```javascript
922
+ import {endCall} from 'omikit-plugin';
799
923
  endCall();
800
- ```
801
- - rejectCall: Used to reject an incoming call when the user has not accepted it yet.
802
- Note: Do not use this function to end an ongoing call.
924
+ ```
803
925
 
804
- ```javascript
805
- import {rejectCall} from 'omikit-plugin';
806
926
 
927
+ 📌 **rejectCall()**
928
+
929
+ ✅ Description: Used to reject an incoming call when the user has not accepted it yet.
930
+
931
+ 📝 Note: Do not use this function to end an ongoing call.
932
+
933
+ ```javascript
934
+ import {rejectCall} from 'omikit-plugin';
807
935
  rejectCall();
808
- ```
809
- - Logout: logout and remove all information.
936
+ ```
810
937
 
811
- ```javascript
812
- import {logout} from 'omikit-plugin';
813
938
 
939
+ 📌 **logout()**
940
+
941
+ ✅ Description: logout and remove all information.
942
+
943
+ ```javascript
944
+ import {logout} from 'omikit-plugin';
814
945
  logout();
815
- ```
946
+ ```
816
947
 
817
- - Permission: Check system alert window permission (only Android).
948
+ 📌 **systemAlertWindow()**
818
949
 
819
- ```javascript
820
- import {systemAlertWindow} from 'omikit-plugin';
950
+ ✅ Description: Check system alert window permission (only Android).
821
951
 
822
- if (Platform.OS === 'android') {
823
- const isAllow = await systemAlertWindow();
952
+ ```javascript
953
+ import {systemAlertWindow} from 'omikit-plugin';
954
+ const isAllow = await systemAlertWindow();
824
955
  //true => allow
825
956
  //false => denied
826
- }
827
- ```
957
+ ```
958
+
828
959
 
829
- - Setting: Open to enable system alert window (only Android).
960
+ 📌 **openSystemAlertSetting()**
830
961
 
831
- ```javascript
832
- import {openSystemAlertSetting} from 'omikit-plugin';
962
+ ✅ Description: Open to enable system alert window (only Android).
963
+
964
+ ```javascript
965
+ import {openSystemAlertSetting} from 'omikit-plugin';
833
966
 
834
967
  if (Platform.OS === 'android') {
835
968
  openSystemAlertSetting();
836
969
  }
837
- ```
838
- - Audio:
839
- - func *getCurrentAudio*: lấy thông tin hiện tại của audio devices
840
- ```javascript
841
- import {getCurrentAudio} from 'omikit-plugin';
970
+ ```
971
+
972
+ 📌 **getCurrentAudio()**
973
+
974
+ Description: Get current information of audio devices
975
+
976
+ ```javascript
977
+ import {getCurrentAudio} from 'omikit-plugin';
842
978
 
843
979
  getCurrentAudio().then((data: any) => {
844
980
  console.log(data); // [{"name": "Speaker", "type": "Speaker"}]
845
- // Ghi chú: Data một mảng chứa thông tin của các thiết bị âm thanh, với các tham số:
846
- // - name: Tên của thiết bị âm thanh
847
- // - type: Loại thiết bị âm thanh ( dụ: "Speaker", "Microphone", v.v.)
981
+ // Note: Data is an array containing information about audio devices, with parameters:
982
+ // - name: Name of the audio device
983
+ // - type: Audio device type (e.g. "Speaker", "Receiver", etc.)
984
+ });
985
+ ```
986
+
987
+ 📌 **setAudio()**
988
+
989
+ ✅ Description: set Audio calls the current device
990
+
991
+ ```javascript
992
+ import { getAudio, setAudio} from 'omikit-plugin';
993
+
994
+ const audioList = await getAudio(); // Get a list of supported audio device types
995
+ console.log("audioList --> ", audioList) // audioList --> [{"name": "Receiver", "type": "Receiver"}, {"name": "Speaker", "type": "Speaker"}]
996
+
997
+ const receiver = audioList.find((element: any) => {
998
+ return element.type === 'Receiver'; // type: "Speaker" is the external speaker, Receiver is the internal speaker
848
999
  });
849
- ```
1000
+
1001
+ setAudio({
1002
+ portType: receiver.type,
1003
+ });
1004
+ ```
850
1005
 
851
- - Video Call functions: Support only video call, You need enable video in `init functions` and `start call` to implements under functions.
1006
+ ##### 📝 Video Call functions: Support only video call, You need enable video in `init functions` and `start call` to implements under functions.
852
1007
 
853
- - Switch front/back camera: We use the front camera for first time.
1008
+ Description: Video Call functions: Support only video call, You need enable video in `init functions` and `start call` to implements under functions.
1009
+
1010
+
1011
+ 📌 Switch front/back camera: We use the front camera for first time.
854
1012
 
855
1013
  ```javascript
856
1014
  import {switchOmiCamera} from 'omikit-plugin';
857
1015
  switchOmiCamera();
858
1016
  ```
859
1017
 
860
- - Toggle a video in video call: On/off video in video call
1018
+ 📌 Toggle a video in video call: On/off video in video call
861
1019
 
862
1020
  ```javascript
863
1021
  import {toggleOmiVideo} from 'omikit-plugin';
864
1022
  toggleOmiVideo();
865
1023
  ```
866
1024
 
867
- - Local Camera Widget: Your camera view in a call
1025
+ 📌 Local Camera Widget: Your camera view in a call
868
1026
 
869
1027
  ```javascript
870
1028
  import { OmiLocalCameraView } from 'omikit-plugin';
871
1029
  <OmiLocalCameraView style={styles.localCamera} />
872
1030
  ```
873
1031
 
874
- - Remote Camera Widget: Remote camera view in a call
1032
+ 📌 Remote Camera Widget: Remote camera view in a call
875
1033
 
876
1034
  ```javascript
877
1035
  import { OmiRemoteCameraView } from 'omikit-plugin';
878
1036
  <OmiRemoteCameraView style={styles.remoteCamera} />
879
1037
  ```
880
1038
 
881
- - More function: Refresh local camera
1039
+ 📌 More function: Refresh local camera
882
1040
 
883
1041
  ```javascript
884
1042
  import {refreshLocalCamera} from 'omikit-plugin';
885
1043
  refreshLocalCamera();
886
1044
  ```
887
1045
 
888
- - More function: Refresh remote camera
1046
+ 📌 More function: Refresh remote camera
889
1047
 
890
1048
  ```javascript
891
1049
  import {refreshRemoteCamera} from 'omikit-plugin';
892
1050
  refreshRemoteCamera();
893
1051
  ```
894
1052
 
895
- - Register event: Register remote video ready: only visible on iOS
1053
+ 📌 Register event: Register remote video ready: only visible on iOS
896
1054
 
897
1055
  ```javascript
898
1056
  import {registerVideoEvent} from 'omikit-plugin';
899
1057
  registerVideoEvent();
900
1058
  ```
901
1059
 
902
- - Event listener:
1060
+ ### 🚀🚀 Events listener 🚀🚀
903
1061
 
904
1062
  ```javascript
905
1063
  useEffect(() => {
@@ -942,38 +1100,95 @@ useEffect(() => {
942
1100
  }, []);
943
1101
  ```
944
1102
 
945
- - Important event `onCallStateChanged`: We provide it to listen call state change.
946
- // OmiAction have 2 variables: actionName and data
1103
+ - ✅ **Important Event: `onCallStateChanged`**
1104
+ This event is used to listen for call state changes. The emitted event is an `OmiAction` object containing two properties: `actionName` and `data`.
1105
+
1106
+ - 📝 **Action Name Values:**
1107
+ - **`onCallStateChanged`**: Indicates that the call state has changed.
1108
+ - **`onSwitchboardAnswer`**: Indicates that the switchboard SIP is listening.
1109
+ - **Call Status Values:**
1110
+ - `unknown` (0)
1111
+ - `calling` (1)
1112
+ - `incoming` (2)
1113
+ - `early` (3)
1114
+ - `connecting` (4)
1115
+ - `confirmed` (5)
1116
+ - `disconnected` (6)
1117
+ - `hold` (7)
947
1118
 
948
- - Action Name value:
949
- - `onCallStateChanged`: Call state changed.
950
- - `onSwitchboardAnswer`: Switchboard sip is listening.
951
- - List status call:
952
- - unknown(0),
953
- - calling(1),
954
- - incoming(2),
955
- - early(3),
956
- - connecting(4),
957
- - confirmed(5),
958
- - disconnected(6);
959
- - hold(7);
1119
+ > **Note:** The `onCallStateChanged` event tracks the current state of the call. Please refer to `OmiCallState` for detailed status descriptions.
960
1120
 
961
- * onCallStateChanged is call state tracking event. We will return status of state. Please refer `OmiCallState`.
962
- `onCallStateChanged value:` + isVideo: value boolean (true is call Video) + status: number (value matching with List status call ) + callerNumber: phone number + incoming: boolean - status call incoming or outgoing + \_id: option (id of every call) + code_end_call: This is code when end call.
1121
+ ### 📞 **Call State Lifecycle**
1122
+ - **Incoming Call Lifecycle:**
1123
+ `incoming` → `connecting` → `confirmed` → `disconnected`
963
1124
 
964
- * `Incoming call` state lifecycle: incoming -> connecting -> confirmed -> disconnected
965
- * `Outgoing call` state lifecycle: calling -> early -> connecting -> confirmed -> disconnected
1125
+ - **Outgoing Call Lifecycle:**
1126
+ `calling` `early` `connecting` `confirmed` `disconnected`
966
1127
 
967
- * onSwitchboardAnswer have callback when employee answered script call.
968
1128
 
969
- - Table describing code_end_call status
1129
+ ```javascript
1130
+ // The event is updated every time the call status changes
1131
+ const onCallStateChanged = (data: any) => {
1132
+ /*
1133
+ Call state change event data (Object) includes:
1134
+
1135
+ - _id: string (UUID of the call)
1136
+ - callInfo: object (Detailed call information)
1137
+ - callerNumber: string (Phone number of the caller)
1138
+ - code_end_call: number (Status code when the call ends)
1139
+ - destination_number?: string (Destination phone number, optional)
1140
+ - direction: string ("inbound" or "outbound", call direction)
1141
+ - disposition: string (Call answer status)
1142
+ - incoming: boolean (true if it is an incoming call)
1143
+ - isVideo: boolean (true if it is a video call)
1144
+ - sip_user: string (Current SIP user)
1145
+ - source_number: string (SIP number of the user)
1146
+ - status: string (value matching with List status call)
1147
+ - time_end: number (Timestamp when the call ended)
1148
+ - time_start_to_answer: number (Time taken to answer the call)
1149
+ - transaction_id: string (OMI Call unique ID)
1150
+ */
1151
+ };
1152
+
1153
+ // Event returned when the user mutes the call
1154
+ const onMuted = (isMuted: boolean) => {
1155
+ // isMuted: true when muted call
1156
+ }
1157
+
1158
+ // Event returns value when user holds call
1159
+ const onHold = (isHold: boolean) => {
1160
+ // isHold: true when hold call
1161
+ }
1162
+
1163
+ // The event updates the quality of an ongoing call
1164
+ const onCallQuality = (data: any) => {
1165
+ const { quality } = data;
1166
+ // quality: int is mean quality off calling
1167
+ // 1 is good, 2 is medium, 3 is low
1168
+ }
1169
+
1170
+ // Even when user turn on speakerphone
1171
+ const onSpeaker = (isSpeaker: boolean) => {
1172
+ // isSpeaker: true, false
1173
+ // True mean speaker devices is open
1174
+ }
1175
+
1176
+ // * onSwitchboardAnswer have callback when employee answered script call.
1177
+ const onSwitchboardAnswer = (data: any) => {
1178
+ const { sip } = data
1179
+ // sip: String
1180
+ }
1181
+ ```
1182
+
1183
+ ✨ Table describing `code_end_call` status
970
1184
 
971
1185
  | Code | Description |
972
1186
  | --------------- | --------------------------------------------------------------------------------------------------------------------- |
973
- | `600, 503, 480` | These are the codes of the network operator or the user who did not answer the call |
1187
+ | `600, 503` | These are the codes of the network operator or the user who did not answer the call |
974
1188
  | `408` | Call request timeout (Each call usually has a waiting time of 30 seconds. If the 30 seconds expire, it will time out) |
975
1189
  | `403` | Your service plan only allows calls to dialed numbers. Please upgrade your service pack|
976
1190
  | `404` | The current number is not allowed to make calls to the carrier|
1191
+ | `480` | The number has an error, please contact support to check the details |
977
1192
  | `603` | The call was rejected. Please check your account limit or call barring configuration! |
978
1193
  | `850` | Simultaneous call limit exceeded, please try again later |
979
1194
  | `486` | The listener refuses the call and does not answer |
@@ -997,25 +1212,9 @@ useEffect(() => {
997
1212
  | `864` | Temporary block on Mobifone direction, please try again |
998
1213
  | `865` | he advertising number is currently outside the permitted calling hours, please try again later |
999
1214
 
1000
- - Action Name value:
1001
- - `OmiCallEvent.onMuted`: Audio changed.
1002
- - `OmiCallEvent.onSpeaker`: Audio changed.
1003
- - `OmiCallEvent.onClickMissedCall`: Click missed call notification.
1004
- - `OmiCallEvent.onSwitchboardAnswer`: Switchboard sip is listening.
1005
- - `OmiCallEvent.onCallQuality`: The calling quality.
1006
- - `OmiCallEvent.onRequestPermission`: Show a list permission you need to request before calling `joinCall` again.
1007
- - `OmiCallEvent.onHold`: hold current call
1008
- - Data value: We return `callerNumber`, `sip`, `isVideo: true/false` information
1009
-
1010
- - Forward calls to internal staff:
1011
- - You can use function `transferCall` for transfer to staff you want.
1012
- example:
1013
- transferCall({
1014
- phoneNumber: 102
1015
- })
1215
+ # ⚠️ Issues
1016
1216
 
1017
- # Issues
1018
1217
 
1019
- ## iOS
1218
+ ## iOS
1020
1219
 
1021
1220
  - Must use "Rosetta Destination" to run debug example app on macOS Apple chip