omikit-plugin 1.0.0 → 2.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.
- package/README.md +296 -66
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/omikitplugin/FLLocalCameraModule.kt +37 -0
- package/android/src/main/java/com/omikitplugin/FLLocalCameraView.kt +23 -0
- package/android/src/main/java/com/omikitplugin/FLRemoteCameraModule.kt +37 -0
- package/android/src/main/java/com/omikitplugin/FLRemoteCameraView.kt +23 -0
- package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +249 -85
- package/android/src/main/java/com/omikitplugin/OmikitPluginPackage.kt +21 -2
- package/android/src/main/java/com/omikitplugin/constants/constant.kt +23 -12
- package/ios/CallProcess/CallManager.swift +109 -71
- package/ios/Constant/Constant.swift +15 -10
- package/ios/OmikitPlugin.m +34 -2
- package/ios/OmikitPlugin.swift +69 -32
- package/ios/VideoCall/FLLocalCameraView.m +17 -0
- package/ios/VideoCall/FLLocalCameraView.swift +41 -80
- package/ios/VideoCall/FLRemoteCameraView.m +18 -0
- package/ios/VideoCall/FLRemoteCameraView.swift +39 -1
- package/lib/commonjs/index.js +32 -64
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/omi_local_camera.js +15 -0
- package/lib/commonjs/omi_local_camera.js.map +1 -0
- package/lib/commonjs/omi_remote_camera.js +15 -0
- package/lib/commonjs/omi_remote_camera.js.map +1 -0
- package/lib/commonjs/omikit.js +98 -0
- package/lib/commonjs/omikit.js.map +1 -0
- package/lib/module/index.js +3 -51
- package/lib/module/index.js.map +1 -1
- package/lib/module/omi_local_camera.js +7 -0
- package/lib/module/omi_local_camera.js.map +1 -0
- package/lib/module/omi_remote_camera.js +7 -0
- package/lib/module/omi_remote_camera.js.map +1 -0
- package/lib/module/omikit.js +73 -0
- package/lib/module/omikit.js.map +1 -0
- package/lib/typescript/index.d.ts +3 -19
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/omi_local_camera.d.ts +5 -0
- package/lib/typescript/omi_local_camera.d.ts.map +1 -0
- package/lib/typescript/omi_remote_camera.d.ts +5 -0
- package/lib/typescript/omi_remote_camera.d.ts.map +1 -0
- package/lib/typescript/omikit.d.ts +26 -0
- package/lib/typescript/omikit.d.ts.map +1 -0
- package/omikit-plugin.podspec +1 -1
- package/package.json +1 -1
- package/src/index.tsx +3 -71
- package/src/omi_local_camera.tsx +11 -0
- package/src/omi_remote_camera.tsx +11 -0
- package/src/omikit.tsx +98 -0
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
|
|
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,154 @@ yarn add omikit-plugin
|
|
|
32
32
|
#### Android:
|
|
33
33
|
|
|
34
34
|
- Add this setting in `build.gradle`:
|
|
35
|
-
|
|
36
35
|
```
|
|
37
|
-
jcenter()
|
|
36
|
+
jcenter()
|
|
38
37
|
maven {
|
|
39
|
-
url("https://
|
|
38
|
+
url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
|
|
40
39
|
credentials {
|
|
41
|
-
username = "
|
|
40
|
+
username = "downloader"
|
|
41
|
+
password = "Omi@2022"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
```
|
|
45
|
-
|
|
46
45
|
```
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
-
|
|
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:exported="false">
|
|
105
|
+
<intent-filter>
|
|
106
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
107
|
+
</intent-filter>
|
|
108
|
+
</service>
|
|
109
|
+
```
|
|
61
110
|
|
|
62
|
-
|
|
111
|
+
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
112
|
|
|
64
|
-
|
|
113
|
+
- We registered permissions into my plugin:
|
|
114
|
+
```
|
|
115
|
+
<uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"
|
|
116
|
+
tools:ignore="ProtectedPermissions" />
|
|
117
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
118
|
+
<uses-permission android:name="android.permission.USE_SIP" />
|
|
119
|
+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
|
120
|
+
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
121
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
122
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
123
|
+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
|
124
|
+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
|
125
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
126
|
+
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
|
127
|
+
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
128
|
+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
|
129
|
+
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
|
130
|
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
131
|
+
```
|
|
65
132
|
|
|
66
|
-
-
|
|
133
|
+
- Setup push notification: We only support Firebase for push notification.
|
|
134
|
+
- Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
|
|
135
|
+
- 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
136
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
137
|
+
- For more setting information, please refer <a href="https://rnfirebase.io/messaging/usage">Config Push for Android</a>
|
|
138
|
+
|
|
139
|
+
#### iOS:
|
|
140
|
+
----
|
|
71
141
|
|
|
72
|
-
|
|
142
|
+
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
143
|
|
|
74
|
-
|
|
75
|
-
@property (nonatomic, strong) PushKitManager *pushkitManager;
|
|
76
|
-
@property (nonatomic, strong) CallKitProviderDelegate * provider;
|
|
77
|
-
@property (nonatomic, strong) PKPushRegistry * voipRegistry;
|
|
144
|
+
---
|
|
78
145
|
|
|
79
|
-
|
|
146
|
+
- Add variables in Appdelegate.h:
|
|
80
147
|
|
|
81
148
|
```
|
|
149
|
+
#import <UIKit/UIKit.h>
|
|
150
|
+
#import <UserNotifications/UserNotifications.h>
|
|
151
|
+
#import <OmiKit/OmiKit-umbrella.h>
|
|
152
|
+
#import <OmiKit/Constants.h>
|
|
153
|
+
#import <UserNotifications/UserNotifications.h>
|
|
82
154
|
|
|
83
|
-
|
|
155
|
+
PushKitManager *pushkitManager;
|
|
156
|
+
CallKitProviderDelegate * provider;
|
|
157
|
+
PKPushRegistry * voipRegistry;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- Edit AppDelegate.m:
|
|
84
161
|
|
|
85
162
|
```
|
|
86
163
|
#import <OmiKit/OmiKit.h>
|
|
164
|
+
#import <omicall_flutter_plugin/omicall_flutter_plugin-Swift.h>
|
|
87
165
|
|
|
88
166
|
[OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX];
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
167
|
+
provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
|
|
168
|
+
voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
|
|
169
|
+
pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- Add this lines into `Info.plist`:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
176
|
+
<string>Need microphone access for make Call</string>
|
|
177
|
+
//If you implement video call
|
|
178
|
+
<key>NSCameraUsageDescription</key>
|
|
179
|
+
<string>Need camera access for video call functions</string>
|
|
93
180
|
```
|
|
94
181
|
|
|
95
|
-
- Save token for `OmiClient
|
|
182
|
+
- Save token for `OmiClient`: You use `Cloud Messaging` into your project so you don't need add this lines.
|
|
96
183
|
|
|
97
184
|
```
|
|
98
185
|
- (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)devToken
|
|
@@ -104,62 +191,205 @@ self.pushkitManager = [[PushKitManager alloc] initWithVoipRegistry: self.voipReg
|
|
|
104
191
|
{
|
|
105
192
|
[token appendFormat:@"%02.2hhX", data[i]];
|
|
106
193
|
}
|
|
107
|
-
|
|
194
|
+
|
|
108
195
|
// print the token in the console.
|
|
109
196
|
NSLog(@"Push Notification Token: %@", [token copy]);
|
|
110
197
|
[OmiClient setUserPushNotificationToken:[token copy]];
|
|
111
198
|
}
|
|
112
199
|
|
|
113
200
|
```
|
|
201
|
+
*** Only use under lines when add `Cloud Messaging` plugin ***
|
|
202
|
+
- Setup push notification: We only support Firebase for push notification.
|
|
203
|
+
- Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
|
|
204
|
+
- 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
205
|
|
|
115
|
-
Push
|
|
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>
|
|
206
|
+
- 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
207
|
|
|
120
208
|
## Implement
|
|
121
209
|
|
|
122
|
-
- Set up
|
|
210
|
+
- Set up <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> plugin:
|
|
123
211
|
|
|
124
212
|
```
|
|
125
213
|
//if you use only on Android. you only implement for Android.
|
|
126
214
|
//because we use APNS to push notification on iOS so you don't need add Firebase for iOS.
|
|
127
215
|
//But you can use firebase-messaging to get APNS token for iOS.
|
|
128
216
|
```
|
|
129
|
-
|
|
130
|
-
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
217
|
+
- Important function.
|
|
218
|
+
- Start Serivce: OmiKit need start services and register some events.
|
|
219
|
+
```
|
|
220
|
+
//Call in the root widget
|
|
221
|
+
import { startServices } from 'omikit-plugin';
|
|
222
|
+
|
|
223
|
+
startServices();
|
|
224
|
+
```
|
|
225
|
+
- Create OmiKit With ApiKey: OmiKit need apikey, username, user id to init enviroment. ViHAT Group will provide api key for you. Please contact for my sale:
|
|
226
|
+
```
|
|
227
|
+
import { initCallWithApiKey } from 'omikit-plugin';
|
|
228
|
+
|
|
229
|
+
const loginInfo = {
|
|
230
|
+
usrUuid: usrUuid,
|
|
231
|
+
fullName: fullName,
|
|
232
|
+
apiKey: apiKey,
|
|
233
|
+
isVideo: isVideo,
|
|
234
|
+
};
|
|
235
|
+
console.log(loginInfo);
|
|
236
|
+
const result = await initCallWithApiKey(loginInfo);
|
|
237
|
+
//result is true then user login successfully.
|
|
238
|
+
```
|
|
239
|
+
- Create OmiKit: OmiKit need userName, password, realm, host to init enviroment. ViHAT Group will provide informations for you. Please contact for my sale:
|
|
240
|
+
```
|
|
241
|
+
import { initCall } from 'omikit-plugin';
|
|
242
|
+
|
|
243
|
+
const loginInfo = {
|
|
244
|
+
userName: userName, //string
|
|
245
|
+
password: password, //string
|
|
246
|
+
realm: realm, //string
|
|
247
|
+
isVideo: isVideo, //boolean: true/false
|
|
248
|
+
host: host, //string
|
|
249
|
+
};
|
|
250
|
+
const result = await initCall(loginInfo);
|
|
251
|
+
//result is true then user login successfully.
|
|
252
|
+
```
|
|
253
|
+
- Config push notification for Android:
|
|
254
|
+
```
|
|
255
|
+
import { configPushNotification } from 'omikit-plugin';
|
|
256
|
+
|
|
257
|
+
configPushNotification({
|
|
258
|
+
prefix: 'Cuộc gọi tới từ: ',
|
|
259
|
+
declineTitle: 'Từ chối',
|
|
260
|
+
acceptTitle: 'Chấp nhận',
|
|
261
|
+
acceptBackgroundColor: '#FF3700B3',
|
|
262
|
+
declineBackgroundColor: '#FF000000',
|
|
263
|
+
incomingBackgroundColor: '#FFFFFFFF',
|
|
264
|
+
incomingAcceptButtonImage: 'join_call',
|
|
265
|
+
incomingDeclineButtonImage: 'hangup',
|
|
266
|
+
backImage: 'ic_back',
|
|
267
|
+
userImage: 'calling_face',
|
|
268
|
+
});
|
|
269
|
+
//incomingAcceptButtonImage, incomingDeclineButtonImage, backImage, userImage: Add these into `android/app/src/main/res/drawble`
|
|
270
|
+
```
|
|
271
|
+
- Get call when user open app from killed status(only iOS):
|
|
272
|
+
```
|
|
273
|
+
import { getInitialCall } from 'omikit-plugin';
|
|
274
|
+
|
|
275
|
+
const callingInfo = await getInitialCall();
|
|
276
|
+
if (callingInfo !== false) {
|
|
277
|
+
navigation.navigate('DialCall' as never, callingInfo as never);
|
|
278
|
+
}
|
|
279
|
+
//callingInfo != false then user have a calling.
|
|
280
|
+
```
|
|
281
|
+
- 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>
|
|
282
|
+
```
|
|
283
|
+
import { updateToken } from 'omikit-plugin';
|
|
284
|
+
|
|
285
|
+
const fcmToken = await fcm;
|
|
286
|
+
const apnsToken = await apns;
|
|
287
|
+
const deviceId = DeviceInfo.getDeviceId();
|
|
288
|
+
const appId = DeviceInfo.getBundleId();
|
|
289
|
+
updateToken({
|
|
290
|
+
apnsToken: apnsToken,
|
|
291
|
+
fcmToken: fcmToken,
|
|
292
|
+
deviceId: deviceId,
|
|
293
|
+
appId: appId,
|
|
294
|
+
});
|
|
295
|
+
```
|
|
296
|
+
- Other functions:
|
|
297
|
+
- Call with phone number (mobile phone or internal number):
|
|
298
|
+
```
|
|
299
|
+
import {startCall} from 'omikit-plugin';
|
|
300
|
+
|
|
301
|
+
const result = await startCall({
|
|
302
|
+
phoneNumber: phone, //phone number
|
|
303
|
+
isVideo: false //allow video call: true/false
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
- Accept a call:
|
|
307
|
+
```
|
|
308
|
+
import {joinCall} from 'omikit-plugin';
|
|
309
|
+
|
|
310
|
+
await joinCall();
|
|
311
|
+
```
|
|
312
|
+
- End a call: We will push a event `endCall` for you.
|
|
313
|
+
```
|
|
314
|
+
import {endCall} from 'omikit-plugin';
|
|
315
|
+
|
|
316
|
+
await endCall();
|
|
317
|
+
```
|
|
318
|
+
- Toggle the audio: On/off audio a call
|
|
319
|
+
```
|
|
320
|
+
import {toggleMute} from 'omikit-plugin';
|
|
321
|
+
|
|
322
|
+
toggleMute();
|
|
323
|
+
```
|
|
324
|
+
- Toggle the speaker: On/off the phone speaker
|
|
325
|
+
```
|
|
326
|
+
import {toggleSpeaker} from 'omikit-plugin';
|
|
327
|
+
|
|
328
|
+
toggleSpeaker();
|
|
329
|
+
```
|
|
330
|
+
- Send character: We only support `1 to 9` and `* #`.
|
|
331
|
+
```
|
|
332
|
+
import {sendDTMF} from 'omikit-plugin';
|
|
333
|
+
|
|
334
|
+
sendDTMF({
|
|
335
|
+
character: text,
|
|
336
|
+
});
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
- Video Call functions: Support only video call, You need enable video in `init functions` and `start call` to implements under functions.
|
|
340
|
+
- Switch front/back camera: We use the front camera for first time.
|
|
341
|
+
```
|
|
342
|
+
import {switchOmiCamera} from 'omikit-plugin';
|
|
343
|
+
switchOmiCamera();
|
|
344
|
+
```
|
|
345
|
+
- Toggle a video in video call: On/off video in video call
|
|
346
|
+
```
|
|
347
|
+
import {toggleOmiVideo} from 'omikit-plugin';
|
|
348
|
+
toggleOmiVideo();
|
|
349
|
+
```
|
|
350
|
+
- Local Camera Widget: Your camera view in a call
|
|
351
|
+
```
|
|
352
|
+
import { OmiLocalCameraView } from 'omikit-plugin';
|
|
353
|
+
<OmiLocalCameraView style={styles.localCamera} />
|
|
354
|
+
```
|
|
355
|
+
- Remote Camera Widget: Remote camera view in a call
|
|
356
|
+
```
|
|
357
|
+
import { OmiRemoteCameraView } from 'omikit-plugin';
|
|
358
|
+
<OmiRemoteCameraView style={styles.remoteCamera} />
|
|
359
|
+
```
|
|
360
|
+
- More function: Refresh local camera
|
|
361
|
+
```
|
|
362
|
+
import {refreshLocalCamera} from 'omikit-plugin';
|
|
363
|
+
refreshLocalCamera();
|
|
364
|
+
```
|
|
365
|
+
- More function: Refresh remote camera
|
|
366
|
+
```
|
|
367
|
+
import {refreshRemoteCamera} from 'omikit-plugin';
|
|
368
|
+
refreshRemoteCamera();
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
- Event listener:
|
|
142
373
|
```
|
|
143
374
|
useEffect(() => {
|
|
144
|
-
omiEmitter.addListener(
|
|
145
|
-
omiEmitter.addListener(
|
|
146
|
-
omiEmitter.addListener(
|
|
147
|
-
omiEmitter.addListener(
|
|
148
|
-
omiEmitter.addListener(
|
|
375
|
+
omiEmitter.addListener(OmiCallEvent.incomingReceived, incomingReceived);
|
|
376
|
+
omiEmitter.addListener(OmiCallEvent.onCallEstablished, onCallEstablished);
|
|
377
|
+
omiEmitter.addListener(OmiCallEvent.onCallEnd, onCallEnd);
|
|
378
|
+
omiEmitter.addListener(OmiCallEvent.onMuted, onMuted);
|
|
379
|
+
omiEmitter.addListener(OmiCallEvent.onSpeaker, onSpeaker);
|
|
149
380
|
return () => {
|
|
150
|
-
omiEmitter.removeAllListeners(
|
|
381
|
+
omiEmitter.removeAllListeners(OmiCallEvent.incomingReceived);
|
|
151
382
|
omiEmitter.removeAllListeners('onCallEstablished');
|
|
152
|
-
omiEmitter.removeAllListeners(
|
|
153
|
-
omiEmitter.removeAllListeners(
|
|
154
|
-
omiEmitter.removeAllListeners(
|
|
383
|
+
omiEmitter.removeAllListeners(OmiCallEvent.onCallEnd);
|
|
384
|
+
omiEmitter.removeAllListeners(OmiCallEvent.onMuted);
|
|
385
|
+
omiEmitter.removeAllListeners(OmiCallEvent.onSpeaker);
|
|
155
386
|
};
|
|
156
387
|
}, []);
|
|
157
|
-
|
|
158
388
|
```
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
389
|
+
- Action Name value:
|
|
390
|
+
- `OmiCallEvent.incomingReceived`: Have a incoming call. On Android this event work only foreground
|
|
391
|
+
- `OmiCallEvent.onCallEstablished`: Connected a call.
|
|
392
|
+
- `OmiCallEvent.onCallEnd`: End a call.
|
|
393
|
+
- `OmiCallEvent.onMuted`: Audio changed.
|
|
394
|
+
- `OmiCallEvent.onSpeaker`: Audio changed.
|
|
395
|
+
- Data value: We return `callerNumber`, `isVideo: true/false` information
|
package/android/build.gradle
CHANGED
|
@@ -96,7 +96,7 @@ dependencies {
|
|
|
96
96
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
97
97
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
98
98
|
|
|
99
|
-
api 'vn.vihat.omicall:omi-sdk:1.0.
|
|
99
|
+
api 'vn.vihat.omicall:omi-sdk:1.0.51'
|
|
100
100
|
|
|
101
101
|
implementation 'androidx.core:core-ktx:1.7.0'
|
|
102
102
|
implementation 'androidx.fragment:fragment-ktx:1.4.0'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.omikitplugin
|
|
2
|
+
|
|
3
|
+
import android.view.Surface
|
|
4
|
+
import android.view.TextureView
|
|
5
|
+
import com.facebook.react.bridge.Promise
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod
|
|
9
|
+
import vn.vihat.omicall.omisdk.OmiClient
|
|
10
|
+
import vn.vihat.omicall.omisdk.videoutils.ScaleManager
|
|
11
|
+
import vn.vihat.omicall.omisdk.videoutils.Size
|
|
12
|
+
|
|
13
|
+
class FLLocalCameraModule(reactContext: ReactApplicationContext, localViewManager: FLLocalCameraView) :
|
|
14
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
15
|
+
|
|
16
|
+
var cameraView: TextureView
|
|
17
|
+
|
|
18
|
+
override fun getName(): String {
|
|
19
|
+
return "FLLocalCameraView"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
init {
|
|
23
|
+
cameraView = localViewManager.localView
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@ReactMethod
|
|
27
|
+
fun refresh(promise: Promise) {
|
|
28
|
+
cameraView.surfaceTexture?.let {
|
|
29
|
+
OmiClient.instance.setupLocalVideoFeed(Surface(it))
|
|
30
|
+
ScaleManager.adjustAspectRatio(cameraView,
|
|
31
|
+
Size(cameraView.width, cameraView.height),
|
|
32
|
+
Size(1280,720)
|
|
33
|
+
)
|
|
34
|
+
promise.resolve(true)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.omikitplugin
|
|
2
|
+
|
|
3
|
+
import android.view.TextureView
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
+
|
|
8
|
+
class FLLocalCameraView(private val context: ReactApplicationContext) :
|
|
9
|
+
SimpleViewManager<TextureView>() {
|
|
10
|
+
val localView : TextureView = TextureView(context)
|
|
11
|
+
|
|
12
|
+
override fun getName(): String {
|
|
13
|
+
return "FLLocalCameraView"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun createViewInstance(p0: ThemedReactContext): TextureView {
|
|
17
|
+
return localView
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fun localViewInstance(): TextureView {
|
|
21
|
+
return localView
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.omikitplugin
|
|
2
|
+
|
|
3
|
+
import android.view.Surface
|
|
4
|
+
import android.view.TextureView
|
|
5
|
+
import com.facebook.react.bridge.Promise
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod
|
|
9
|
+
import vn.vihat.omicall.omisdk.OmiClient
|
|
10
|
+
import vn.vihat.omicall.omisdk.videoutils.ScaleManager
|
|
11
|
+
import vn.vihat.omicall.omisdk.videoutils.Size
|
|
12
|
+
|
|
13
|
+
class FLRemoteCameraModule(reactContext: ReactApplicationContext, remoteViewManager: FLRemoteCameraView) :
|
|
14
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
15
|
+
|
|
16
|
+
var cameraView: TextureView
|
|
17
|
+
|
|
18
|
+
override fun getName(): String {
|
|
19
|
+
return "FLRemoteCameraView"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
init {
|
|
23
|
+
cameraView = remoteViewManager.remoteView
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@ReactMethod
|
|
27
|
+
fun refresh(promise: Promise) {
|
|
28
|
+
cameraView.surfaceTexture?.let {
|
|
29
|
+
OmiClient.instance.setupIncomingVideoFeed(Surface(it))
|
|
30
|
+
ScaleManager.adjustAspectRatio(cameraView,
|
|
31
|
+
Size(cameraView.width, cameraView.height),
|
|
32
|
+
Size(1280,720)
|
|
33
|
+
)
|
|
34
|
+
promise.resolve(true)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.omikitplugin
|
|
2
|
+
|
|
3
|
+
import android.view.TextureView
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
+
|
|
8
|
+
class FLRemoteCameraView(private val context: ReactApplicationContext) :
|
|
9
|
+
SimpleViewManager<TextureView>() {
|
|
10
|
+
val remoteView : TextureView = TextureView(context)
|
|
11
|
+
|
|
12
|
+
override fun getName(): String {
|
|
13
|
+
return "FLRemoteCameraView"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun createViewInstance(p0: ThemedReactContext): TextureView {
|
|
17
|
+
return remoteView
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fun localViewInstance(): TextureView {
|
|
21
|
+
return remoteView
|
|
22
|
+
}
|
|
23
|
+
}
|