omikit-plugin 0.3.1 → 1.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 CHANGED
@@ -11,20 +11,20 @@ The most important part of the framework is :
11
11
 
12
12
  ## Status
13
13
 
14
- Currently active maintained
14
+ Currently active maintainance and improve performance
15
15
 
16
16
  ## Running
17
17
 
18
18
  Install via npm:
19
19
 
20
20
  ```sh
21
- npm install omikit-plugin
21
+ npm install omikit-plugin@latest
22
22
  ```
23
23
 
24
24
  Install via yarn:
25
25
 
26
26
  ```sh
27
- yarn add omikit-plugin
27
+ yarn add omikit-plugin --latest
28
28
  ```
29
29
 
30
30
  ### Configuration
@@ -32,67 +32,155 @@ yarn add omikit-plugin
32
32
  #### Android:
33
33
 
34
34
  - Add this setting in `build.gradle`:
35
-
36
35
  ```
37
- jcenter() // Warning: this repository is going to shut down soon
36
+ jcenter()
38
37
  maven {
39
- url("https://vihat.jfrog.io/artifactory/vihat-local-repo")
38
+ url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
40
39
  credentials {
41
- username = "anonymous"
40
+ username = "downloader"
41
+ password = "Omi@2022"
42
42
  }
43
43
  }
44
44
  ```
45
-
46
45
  ```
47
- classpath 'com.google.gms:google-services:4.3.13' //in dependencies
46
+ //in dependencies
47
+ classpath 'com.google.gms:google-services:4.3.13'
48
+ ```
49
+ ```
50
+ //under buildscript
51
+ allprojects {
52
+ repositories {
53
+ maven {
54
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
55
+ url("$rootDir/../node_modules/react-native/android")
56
+ }
57
+ maven {
58
+ // Android JSC is installed from npm
59
+ url("$rootDir/../node_modules/jsc-android/dist")
60
+ }
61
+ mavenCentral {
62
+ // We don't want to fetch react-native from Maven Central as there are
63
+ // older versions over there.
64
+ content {
65
+ excludeGroup "com.facebook.react"
66
+ }
67
+ }
68
+ google()
69
+ maven { url 'https://www.jitpack.io' }
70
+ maven {
71
+ url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
72
+ credentials {
73
+ username = "downloader"
74
+ password = "Omi@2022"
75
+ }
76
+ }
77
+ }
78
+ }
48
79
  ```
49
80
 
50
- - Add this setting In `app/build.gradle`:
81
+ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blob/main/example/android/build.gradle">android/build.gradle</a> to know more informations.
51
82
 
83
+ - Add this setting In `app/build.gradle`:
52
84
  ```
53
85
  apply plugin: 'com.android.application'
54
86
  apply plugin: 'kotlin-android'
55
87
  apply plugin: 'com.google.gms.google-services'
56
88
  ```
57
89
 
58
- Push Notification:
90
+ 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.
59
91
 
60
- - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/">Firebase core</a>)
92
+ - Update AndroidManifest.xml:
93
+ ```
94
+ //need request this permission
95
+ <uses-permission android:name="android.permission.INTERNET" />
96
+ //add this lines inside <activity>
97
+ <intent-filter>
98
+ <action android:name="com.omicall.sdk.CallingActivity"/>
99
+ <category android:name="android.intent.category.DEFAULT" />
100
+ </intent-filter>
101
+ //add this lines outside <activity>
102
+ <service
103
+ android:name="vn.vihat.omicall.omisdk.service.FMService"
104
+ android:enabled="true"
105
+ android:exported="false">
106
+ <intent-filter>
107
+ <action android:name="com.google.firebase.MESSAGING_EVENT" />
108
+ </intent-filter>
109
+ </service>
110
+ ```
61
111
 
62
- - For more setting information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/android-sdk/cau-hinh-push-notification">Omicall Config Push for Android</a>
112
+ 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.
63
113
 
64
- #### iOS: Set up environment and library:
114
+ - We registered permissions into my plugin:
115
+ ```
116
+ <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"
117
+ tools:ignore="ProtectedPermissions" />
118
+ <uses-permission android:name="android.permission.INTERNET" />
119
+ <uses-permission android:name="android.permission.USE_SIP" />
120
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
121
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
122
+ <uses-permission android:name="android.permission.CAMERA" />
123
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
124
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
125
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
126
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
127
+ <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
128
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
129
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
130
+ <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
131
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
132
+ ```
65
133
 
66
- - AppDelete.h
134
+ - Setup push notification: We only support Firebase for push notification.
135
+ - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
136
+ - Add Fire Messaging to receive `fcm_token` (You can refer <a href="https://pub.dev/packages/firebase_messaging">Cloud Messaging</a> to setup notification for Flutter)
67
137
 
68
- ```
69
- #import <OmiKit/OmiKit-umbrella.h>
70
- #import <UserNotifications/UserNotifications.h>
138
+ - For more setting information, please refer <a href="https://rnfirebase.io/messaging/usage">Config Push for Android</a>
139
+
140
+ #### iOS:
141
+ ----
71
142
 
72
- @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
143
+ We support both Object-C and Swift. But we only support documents for Object-C. We will write for Swift language later. Thank you.
73
144
 
74
- @property (nonatomic, strong) UIWindow *window;
75
- @property (nonatomic, strong) PushKitManager *pushkitManager;
76
- @property (nonatomic, strong) CallKitProviderDelegate * provider;
77
- @property (nonatomic, strong) PKPushRegistry * voipRegistry;
145
+ ---
78
146
 
79
- @end
147
+ - Add variables in Appdelegate.h:
148
+
149
+ ```
150
+ #import <UIKit/UIKit.h>
151
+ #import <UserNotifications/UserNotifications.h>
152
+ #import <OmiKit/OmiKit-umbrella.h>
153
+ #import <OmiKit/Constants.h>
154
+ #import <UserNotifications/UserNotifications.h>
80
155
 
156
+ PushKitManager *pushkitManager;
157
+ CallKitProviderDelegate * provider;
158
+ PKPushRegistry * voipRegistry;
81
159
  ```
82
160
 
83
- - AppDelete.m
161
+ - Edit AppDelegate.m:
84
162
 
85
163
  ```
86
164
  #import <OmiKit/OmiKit.h>
165
+ #import <omicall_flutter_plugin/omicall_flutter_plugin-Swift.h>
87
166
 
88
167
  [OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX];
89
- self.provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
90
- self.voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
91
- self.pushkitManager = [[PushKitManager alloc] initWithVoipRegistry: self.voipRegistry];
92
- //Add into `didFinishLaunchingWithOptions` function
168
+ provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
169
+ voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
170
+ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
93
171
  ```
94
172
 
95
- - Save token for `OmiClient`, if you don't use `Messaging` for iOS:
173
+ - Add this lines into `Info.plist`:
174
+
175
+ ```
176
+ <key>NSMicrophoneUsageDescription</key>
177
+ <string>Need microphone access for make Call</string>
178
+ //If you implement video call
179
+ <key>NSCameraUsageDescription</key>
180
+ <string>Need camera access for video call functions</string>
181
+ ```
182
+
183
+ - Save token for `OmiClient`: You use `Cloud Messaging` into your project so you don't need add this lines.
96
184
 
97
185
  ```
98
186
  - (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)devToken
@@ -104,40 +192,102 @@ self.pushkitManager = [[PushKitManager alloc] initWithVoipRegistry: self.voipReg
104
192
  {
105
193
  [token appendFormat:@"%02.2hhX", data[i]];
106
194
  }
107
-
195
+
108
196
  // print the token in the console.
109
197
  NSLog(@"Push Notification Token: %@", [token copy]);
110
198
  [OmiClient setUserPushNotificationToken:[token copy]];
111
199
  }
112
200
 
113
201
  ```
202
+ *** Only use under lines when add `Cloud Messaging` plugin ***
203
+ - Setup push notification: We only support Firebase for push notification.
204
+ - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
205
+ - 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)
114
206
 
115
- Push Notification:
116
- Omicall need two certificates: VOIP Push Certificate & User Push Notification Certificate
117
-
118
- - For more information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/ios-sdk/cau-hinh-push-notification">Omicall Push Notification for iOS</a>
207
+ - 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>
119
208
 
120
209
  ## Implement
121
210
 
122
- - Set up Firebase Messaging: <a href="https://rnfirebase.io/messaging/usage">messaging</a> plugin.
211
+ - Set up <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> plugin:
123
212
 
124
213
  ```
125
214
  //if you use only on Android. you only implement for Android.
126
215
  //because we use APNS to push notification on iOS so you don't need add Firebase for iOS.
127
216
  //But you can use firebase-messaging to get APNS token for iOS.
128
217
  ```
129
-
130
- - Call actions:
131
-
132
- * `initCall` : register and init OmiCall. You need send Object value with `userName`, `password` and `realm`.
133
- * `updateToken` : update token for sdk. You need send `fcmToken` for Android and send `apnsToken` for iOS.
134
- * `startCall` : start Call.
135
- * `endCall` : end Call.
136
- * `toggleMute` : toggle the microphone status.
137
- * `toggleSpeaker` : toggle the voice status. You need send Object value with `useSpeaker`.
138
- * `sendDTMF` : send DTMF for call server. You need send Object value with `character` value.
139
-
140
- * Event listener:
218
+ - Important function.
219
+ - Create OmiKit: OmiKit need userName, password, realm, host to init enviroment. ViHAT Group will provide informations for you. Please contact for my sale:
220
+ ```
221
+ import { initCall } from 'omikit-plugin';
222
+
223
+ const loginInfo = {
224
+ userName: userName, //string
225
+ password: password, //string
226
+ realm: realm, //string
227
+ isVideo: isVideo, //boolean: true/false
228
+ host: host, //string
229
+ };
230
+ const result = await initCall(loginInfo);
231
+ ```
232
+ - 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>
233
+ ```
234
+ import { updateToken } from 'omikit-plugin';
235
+
236
+ const fcmToken = await fcm;
237
+ const apnsToken = await apns;
238
+ const deviceId = DeviceInfo.getDeviceId();
239
+ const appId = DeviceInfo.getBundleId();
240
+ updateToken({
241
+ apnsToken: apnsToken,
242
+ fcmToken: fcmToken,
243
+ deviceId: deviceId,
244
+ appId: appId,
245
+ });
246
+ ```
247
+ - Other functions:
248
+ - Call with phone number (mobile phone or internal number):
249
+ ```
250
+ import {startCall} from 'omikit-plugin';
251
+
252
+ const result = await startCall({
253
+ phoneNumber: phone, //phone number
254
+ isVideo: false //allow video call: true/false
255
+ });
256
+ ```
257
+ - Accept a call:
258
+ ```
259
+ import {joinCall} from 'omikit-plugin';
260
+
261
+ await joinCall();
262
+ ```
263
+ - End a call: We will push a event `endCall` for you.
264
+ ```
265
+ import {endCall} from 'omikit-plugin';
266
+
267
+ await endCall();
268
+ ```
269
+ - Toggle the audio: On/off audio a call
270
+ ```
271
+ import {toggleMute} from 'omikit-plugin';
272
+
273
+ toggleMute();
274
+ ```
275
+ - Toggle the speaker: On/off the phone speaker
276
+ ```
277
+ import {toggleSpeak} from 'omikit-plugin';
278
+
279
+ toggleSpeak();
280
+ ```
281
+ - Send character: We only support `1 to 9` and `* #`.
282
+ ```
283
+ import {sendDTMF} from 'omikit-plugin';
284
+
285
+ sendDTMF({
286
+ character: text,
287
+ });
288
+ ```
289
+
290
+ - Event listener:
141
291
 
142
292
  ```
143
293
  useEffect(() => {
@@ -145,21 +295,17 @@ useEffect(() => {
145
295
  omiEmitter.addListener('onCallEstablished', onCallEstablished);
146
296
  omiEmitter.addListener('onCallEnd', onCallEnd);
147
297
  omiEmitter.addListener('onMuted', onMuted);
148
- omiEmitter.addListener('onRinging', onRinging);
149
298
  return () => {
150
299
  omiEmitter.removeAllListeners('incomingReceived');
151
300
  omiEmitter.removeAllListeners('onCallEstablished');
152
301
  omiEmitter.removeAllListeners('onCallEnd');
153
302
  omiEmitter.removeAllListeners('onMuted');
154
- omiEmitter.removeAllListeners('onRinging');
155
303
  };
156
304
  }, []);
157
-
158
305
  ```
159
-
160
- * Event List: `We support 5 events`
161
- * `onCallEnd`: Trigger when end the call.
162
- * `onCallEstablished`: Trigger when we created the call.
163
- * `onRinging`: Trigger when the phone is ringing.
164
- * `onHold`: Trigger when user hold the call. From parameters, you can reviceved correct status from server through `isHold`
165
- * `onMuted`: Trigger when user muted the call. From parameters, you can reviceved correct status from server through `isMuted`
306
+ - Action Name value:
307
+ - `incomingReceived`: Have a incoming call. On Android this event work only foreground
308
+ - `onCallEstablished`: Connected a call.
309
+ - `onCallEnd`: End a call.
310
+ - `onMuted`: Audio changed.
311
+ - Data value: We return `callerNumber`, `isVideo: true/false` information
@@ -70,19 +70,6 @@ android {
70
70
 
71
71
  }
72
72
 
73
- repositories {
74
- mavenCentral()
75
- google()
76
- jcenter() // Warning: this repository is going to shut down soon
77
- maven {
78
- url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
79
- credentials {
80
- username = "downloader"
81
- password = "Omi@2022"
82
- }
83
- }
84
- }
85
-
86
73
  allprojects {
87
74
  repositories {
88
75
  google()
@@ -109,7 +96,7 @@ dependencies {
109
96
  implementation "com.facebook.react:react-native:+" // From node_modules
110
97
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
111
98
 
112
- api 'vn.vihat.omicall:omi-sdk:0.9.12'
99
+ api 'vn.vihat.omicall:omi-sdk:1.0.10'
113
100
 
114
101
  implementation 'androidx.core:core-ktx:1.7.0'
115
102
  implementation 'androidx.fragment:fragment-ktx:1.4.0'
@@ -124,6 +111,14 @@ dependencies {
124
111
  implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
125
112
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
126
113
  implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
114
+ implementation 'androidx.databinding:viewbinding:7.1.2'
115
+ implementation("com.squareup.retrofit2:retrofit:2.9.0") {
116
+ exclude module: 'okhttp'
117
+ }
118
+ implementation "com.squareup.retrofit2:converter-gson:2.9.0"
119
+ implementation "com.squareup.okhttp3:okhttp:4.9.1"
120
+ implementation "com.squareup.okhttp3:okhttp-urlconnection:4.9.1"
121
+ implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
127
122
  }
128
123
 
129
124
  if (isNewArchitectureEnabled()) {