omikit-plugin 2.3.4 → 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 (40) hide show
  1. package/README.md +129 -41
  2. package/android/build.gradle +4 -1
  3. package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +133 -93
  4. package/android/src/main/java/com/omikitplugin/constants/constant.kt +2 -3
  5. package/android/src/main/java/com/omikitplugin/state/CallState.kt +12 -0
  6. package/ios/CallProcess/CallManager.swift +191 -216
  7. package/ios/CallProcess/CallState.swift +17 -0
  8. package/ios/Constant/Constant.swift +2 -6
  9. package/ios/Library/OmikitPlugin.m +18 -0
  10. package/ios/Library/OmikitPlugin.swift +42 -20
  11. package/lib/commonjs/index.js +22 -0
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/omi_call_state.js +18 -0
  14. package/lib/commonjs/omi_call_state.js.map +1 -0
  15. package/lib/commonjs/omi_start_call_status.js +21 -0
  16. package/lib/commonjs/omi_start_call_status.js.map +1 -0
  17. package/lib/commonjs/omikit.js +15 -10
  18. package/lib/commonjs/omikit.js.map +1 -1
  19. package/lib/module/index.js +2 -0
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/module/omi_call_state.js +11 -0
  22. package/lib/module/omi_call_state.js.map +1 -0
  23. package/lib/module/omi_start_call_status.js +14 -0
  24. package/lib/module/omi_start_call_status.js.map +1 -0
  25. package/lib/module/omikit.js +12 -10
  26. package/lib/module/omikit.js.map +1 -1
  27. package/lib/typescript/index.d.ts +2 -0
  28. package/lib/typescript/index.d.ts.map +1 -1
  29. package/lib/typescript/omi_call_state.d.ts +10 -0
  30. package/lib/typescript/omi_call_state.d.ts.map +1 -0
  31. package/lib/typescript/omi_start_call_status.d.ts +13 -0
  32. package/lib/typescript/omi_start_call_status.d.ts.map +1 -0
  33. package/lib/typescript/omikit.d.ts +7 -6
  34. package/lib/typescript/omikit.d.ts.map +1 -1
  35. package/omikit-plugin.podspec +1 -1
  36. package/package.json +1 -1
  37. package/src/index.tsx +2 -0
  38. package/src/omi_call_state.tsx +9 -0
  39. package/src/omi_start_call_status.tsx +12 -0
  40. package/src/omikit.tsx +16 -11
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,17 +143,13 @@ 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
- #### iOS:
147
-
148
- ---
149
-
150
- We support both Object-C and Swift. But we only support documents for Object-C. We will write for Swift language later. Thank you.
150
+ #### iOS(Object-C):
151
151
 
152
- ---
152
+ - Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
153
153
 
154
154
  - Add variables in Appdelegate.h:
155
155
 
@@ -175,7 +175,7 @@ We support both Object-C and Swift. But we only support documents for Object-C.
175
175
  #import <OmiKit/OmiKit.h>
176
176
  #import <omicall_flutter_plugin/omicall_flutter_plugin-Swift.h>
177
177
 
178
- [OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX];
178
+ [OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX userNameKey:@"full_name" maxCall:2 callKitImage:@"call_image"];
179
179
  provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
180
180
  voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
181
181
  pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
@@ -230,7 +230,74 @@ if (@available(iOS 10.0, *)) {
230
230
 
231
231
  ```
232
232
 
233
- **_ Only use under lines when added `Cloud Messaging` plugin in your project _**
233
+
234
+ *** Only use under lines when added `Cloud Messaging` plugin in your project ***
235
+
236
+ - Setup push notification: We only support Firebase for push notification.
237
+
238
+ - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
239
+ - 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)
240
+
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>
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
+
251
+ #### iOS(Swift):
252
+ - Assets: Add `call_image` into assets folder to update callkit image. We only support png style.
253
+
254
+ - Add variables in Appdelegate.swift:
255
+
256
+ ```
257
+ import OmiKit
258
+ import PushKit
259
+ import NotificationCenter
260
+
261
+ var pushkitManager: PushKitManager?
262
+ var provider: CallKitProviderDelegate?
263
+ var voipRegistry: PKPushRegistry?
264
+ ```
265
+
266
+ - Add these lines into `didFinishLaunchingWithOptions`:
267
+
268
+ ```
269
+ OmiClient.setEnviroment(KEY_OMI_APP_ENVIROMENT_SANDBOX, userNameKey: "extension", maxCall: 1, callKitImage: "call_image")
270
+ provider = CallKitProviderDelegate.init(callManager: OMISIPLib.sharedInstance().callManager)
271
+ voipRegistry = PKPushRegistry.init(queue: .main)
272
+ pushkitManager = PushKitManager.init(voipRegistry: voipRegistry)
273
+ ```
274
+
275
+ - Add these lines into `Info.plist`:
276
+
277
+ ```
278
+ <key>NSCameraUsageDescription</key>
279
+ <string>Need camera access for video call functions</string>
280
+ <key>NSMicrophoneUsageDescription</key>
281
+ <string>Need microphone access for make Call</string>
282
+ ```
283
+
284
+ - Save token for `OmiClient`: if you added `firebase_messaging` in your project so you don't need add these lines.
285
+
286
+ ```
287
+ func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
288
+ let deviceTokenString = deviceToken.hexString
289
+ OmiClient.setUserPushNotificationToken(deviceTokenString)
290
+ }
291
+
292
+ extension Data {
293
+ var hexString: String {
294
+ let hexString = map { String(format: "%02.2hhx", $0) }.joined()
295
+ return hexString
296
+ }
297
+ }
298
+ ```
299
+
300
+ *** Only use under lines when added `Cloud Messaging` plugin in your project ***
234
301
 
235
302
  - Setup push notification: We only support Firebase for push notification.
236
303
 
@@ -238,6 +305,14 @@ if (@available(iOS 10.0, *)) {
238
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)
239
306
 
240
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
+ ```
315
+
241
316
 
242
317
  ## Implement
243
318
 
@@ -269,9 +344,9 @@ if (@available(iOS 10.0, *)) {
269
344
  usrUuid: usrUuid,
270
345
  fullName: fullName,
271
346
  apiKey: apiKey,
347
+ phone: phone,
272
348
  isVideo: isVideo,
273
349
  };
274
- console.log(loginInfo);
275
350
  const result = await initCallWithApiKey(loginInfo);
276
351
  //result is true then user login successfully.
277
352
  ```
@@ -309,22 +384,12 @@ if (@available(iOS 10.0, *)) {
309
384
  missedCallTitle: 'Cuộc gọi nhỡ', //config title for the missed call
310
385
  userNameKey: 'uuid', //we have 3 values: uuid, full_name, extension.
311
386
  channelId: 'com.channel.sample', //your notification channel id
387
+ audioNotificationDescription: '' //audio description
388
+ videoNotificationDescription: '' //video descriptipn
312
389
  });
313
390
  //incomingAcceptButtonImage, incomingDeclineButtonImage, backImage, userImage: Add these into `android/app/src/main/res/drawble`
314
391
  ```
315
392
 
316
- - Get call when user open app from killed status(only iOS):
317
-
318
- ```
319
- import { getInitialCall } from 'omikit-plugin';
320
-
321
- const callingInfo = await getInitialCall();
322
- if (callingInfo !== false) {
323
- navigation.navigate('DialCall' as never, callingInfo as never);
324
- }
325
- //callingInfo != false then user have a calling.
326
- ```
327
-
328
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>
329
394
 
330
395
  ```
@@ -341,6 +406,18 @@ if (@available(iOS 10.0, *)) {
341
406
  });
342
407
  ```
343
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
+
344
421
  - Other functions:
345
422
 
346
423
  - Call with phone number (mobile phone or internal number):
@@ -351,6 +428,17 @@ if (@available(iOS 10.0, *)) {
351
428
  phoneNumber: phone, //phone number
352
429
  isVideo: false //allow video call: true/false
353
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.
354
442
  ```
355
443
 
356
444
  - Call with UUID (only support with Api key):
@@ -361,6 +449,7 @@ if (@available(iOS 10.0, *)) {
361
449
  usrUuid: uuid, //phone number
362
450
  isVideo: false //allow video call: true/false
363
451
  });
452
+ // Result is the same with startCall
364
453
  ```
365
454
 
366
455
  - Accept a call:
@@ -452,7 +541,7 @@ if (@available(iOS 10.0, *)) {
452
541
  }
453
542
  ```
454
543
 
455
- - Logout: Can't receive call.
544
+ - Logout: logout and remove all information.
456
545
 
457
546
  ```
458
547
  import {logout} from 'omikit-plugin';
@@ -535,9 +624,7 @@ if (@available(iOS 10.0, *)) {
535
624
 
536
625
  ```
537
626
  useEffect(() => {
538
- omiEmitter.addListener(OmiCallEvent.incomingReceived, incomingReceived);
539
- omiEmitter.addListener(OmiCallEvent.onCallEstablished, onCallEstablished);
540
- omiEmitter.addListener(OmiCallEvent.onCallEnd, onCallEnd);
627
+ omiEmitter.addListener(OmiCallEvent.onCallStateChanged, onCallStateChanged);
541
628
  omiEmitter.addListener(OmiCallEvent.onMuted, onMuted);
542
629
  omiEmitter.addListener(OmiCallEvent.onSpeaker, onSpeaker);
543
630
  omiEmitter.addListener(OmiCallEvent.onClickMissedCall, clickMissedCall);
@@ -551,9 +638,7 @@ useEffect(() => {
551
638
  );
552
639
  }
553
640
  return () => {
554
- omiEmitter.removeAllListeners(OmiCallEvent.incomingReceived);
555
- omiEmitter.removeAllListeners('onCallEstablished');
556
- omiEmitter.removeAllListeners(OmiCallEvent.onCallEnd);
641
+ omiEmitter.removeAllListeners(OmiCallEvent.onCallStateChanged);
557
642
  omiEmitter.removeAllListeners(OmiCallEvent.onMuted);
558
643
  omiEmitter.removeAllListeners(OmiCallEvent.onSpeaker);
559
644
  omiEmitter.removeAllListeners(OmiCallEvent.onSwitchboardAnswer);
@@ -565,10 +650,13 @@ useEffect(() => {
565
650
  }, []);
566
651
  ```
567
652
 
653
+ - Important event `onCallStateChanged`: We provide it to listen call state change.
654
+
655
+ + It is call state tracking event. We will return status of state. Please refer `OmiCallState`.
656
+ + Incoming call state lifecycle: incoming(receive on foreround state) -> early -> connecting -> confirmed -> disconnected
657
+ + Outgoing call state lifecycle: calling -> early (call created) -> connecting -> confirmed -> disconnected
658
+
568
659
  - Action Name value:
569
- - `OmiCallEvent.incomingReceived`: Have a incoming call. On Android this event work only foreground
570
- - `OmiCallEvent.onCallEstablished`: Connected a call.
571
- - `OmiCallEvent.onCallEnd`: End a call and return call information (like endCall)
572
660
  - `OmiCallEvent.onMuted`: Audio changed.
573
661
  - `OmiCallEvent.onSpeaker`: Audio changed.
574
662
  - `OmiCallEvent.onClickMissedCall`: Click missed call notification.
@@ -68,6 +68,9 @@ android {
68
68
  targetCompatibility JavaVersion.VERSION_1_8
69
69
  }
70
70
 
71
+ dataBinding {
72
+ enabled = true
73
+ }
71
74
  }
72
75
 
73
76
  allprojects {
@@ -96,7 +99,7 @@ dependencies {
96
99
  implementation "com.facebook.react:react-native:+" // From node_modules
97
100
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98
101
 
99
- api 'vn.vihat.omicall:omi-sdk:1.3.6'
102
+ api 'vn.vihat.omicall:omi-sdk:1.4.40'
100
103
  // implementation fileTree(include: ['*.jar'], dir: 'libs')
101
104
  // implementation files('OmiSDK.aar')
102
105
  implementation 'androidx.appcompat:appcompat:1.5.0'