omikit-plugin 2.1.2 → 2.2.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 +198 -81
- package/android/build.gradle +2 -1
- package/android/src/main/java/com/omikitplugin/FLLocalCameraModule.kt +6 -9
- package/android/src/main/java/com/omikitplugin/FLLocalCameraView.kt +25 -4
- package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +178 -27
- package/android/src/main/java/com/omikitplugin/constants/constant.kt +4 -0
- package/ios/CallProcess/CallManager.swift +118 -39
- package/ios/Constant/Constant.swift +6 -1
- package/ios/Library/OmikitNotification.h +17 -0
- package/ios/Library/OmikitNotification.m +15 -0
- package/ios/{OmikitPlugin.m → Library/OmikitPlugin.m} +12 -3
- package/ios/{OmikitPlugin.swift → Library/OmikitPlugin.swift} +51 -15
- package/ios/OmikitPlugin-Bridging-Header.h +12 -2
- package/ios/VideoCall/FLLocalCameraView.swift +5 -3
- package/ios/VideoCall/FLRemoteCameraView.swift +5 -3
- package/lib/commonjs/omikit.js +14 -2
- package/lib/commonjs/omikit.js.map +1 -1
- package/lib/module/omikit.js +11 -2
- package/lib/module/omikit.js.map +1 -1
- package/lib/typescript/omikit.d.ts +4 -0
- package/lib/typescript/omikit.d.ts.map +1 -1
- package/omikit-plugin.podspec +1 -1
- package/package.json +1 -1
- package/src/omikit.tsx +13 -1
package/README.md
CHANGED
|
@@ -32,8 +32,9 @@ yarn add omikit-plugin --latest
|
|
|
32
32
|
#### Android:
|
|
33
33
|
|
|
34
34
|
- Add these settings in `build.gradle`:
|
|
35
|
+
|
|
35
36
|
```
|
|
36
|
-
jcenter()
|
|
37
|
+
jcenter()
|
|
37
38
|
maven {
|
|
38
39
|
url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
|
|
39
40
|
credentials {
|
|
@@ -42,10 +43,12 @@ maven {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
```
|
|
46
|
+
|
|
45
47
|
```
|
|
46
48
|
//in dependencies
|
|
47
49
|
classpath 'com.google.gms:google-services:4.3.13'
|
|
48
50
|
```
|
|
51
|
+
|
|
49
52
|
```
|
|
50
53
|
//under buildscript
|
|
51
54
|
allprojects {
|
|
@@ -81,15 +84,16 @@ allprojects {
|
|
|
81
84
|
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.
|
|
82
85
|
|
|
83
86
|
- Add these settings in `app/build.gradle`:
|
|
87
|
+
|
|
84
88
|
```
|
|
85
89
|
apply plugin: 'com.android.application'
|
|
86
|
-
apply plugin: 'kotlin-android'
|
|
87
90
|
apply plugin: 'com.google.gms.google-services'
|
|
88
91
|
```
|
|
89
92
|
|
|
90
93
|
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.
|
|
91
94
|
|
|
92
95
|
- Update AndroidManifest.xml:
|
|
96
|
+
|
|
93
97
|
```
|
|
94
98
|
//need request this permission
|
|
95
99
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
@@ -99,18 +103,20 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
|
|
|
99
103
|
<category android:name="android.intent.category.DEFAULT" />
|
|
100
104
|
</intent-filter>
|
|
101
105
|
//add this lines outside <activity>
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</
|
|
106
|
+
<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>
|
|
113
|
+
</receiver>
|
|
109
114
|
```
|
|
110
115
|
|
|
111
116
|
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.
|
|
112
117
|
|
|
113
118
|
- We registered permissions into my plugin:
|
|
119
|
+
|
|
114
120
|
```
|
|
115
121
|
<uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"
|
|
116
122
|
tools:ignore="ProtectedPermissions" />
|
|
@@ -131,13 +137,15 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
|
|
|
131
137
|
```
|
|
132
138
|
|
|
133
139
|
- Setup remote push notification: Only support Firebase for remote push notification.
|
|
140
|
+
|
|
134
141
|
- Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
|
|
135
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)
|
|
136
143
|
|
|
137
144
|
- For more setting information, please refer <a href="https://rnfirebase.io/messaging/usage">Config Push for Android</a>
|
|
138
145
|
|
|
139
146
|
#### iOS:
|
|
140
|
-
|
|
147
|
+
|
|
148
|
+
---
|
|
141
149
|
|
|
142
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.
|
|
143
151
|
|
|
@@ -150,11 +158,15 @@ We support both Object-C and Swift. But we only support documents for Object-C.
|
|
|
150
158
|
#import <UserNotifications/UserNotifications.h>
|
|
151
159
|
#import <OmiKit/OmiKit-umbrella.h>
|
|
152
160
|
#import <OmiKit/Constants.h>
|
|
153
|
-
#import <UserNotifications/UserNotifications.h>
|
|
154
161
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>
|
|
163
|
+
|
|
164
|
+
@property (nonatomic, strong) UIWindow *window;
|
|
165
|
+
@property (nonatomic, strong) PushKitManager *pushkitManager;
|
|
166
|
+
@property (nonatomic, strong) CallKitProviderDelegate * provider;
|
|
167
|
+
@property (nonatomic, strong) PKPushRegistry * voipRegistry;
|
|
168
|
+
|
|
169
|
+
@end
|
|
158
170
|
```
|
|
159
171
|
|
|
160
172
|
- Edit AppDelegate.m:
|
|
@@ -167,9 +179,28 @@ PKPushRegistry * voipRegistry;
|
|
|
167
179
|
provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
|
|
168
180
|
voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
|
|
169
181
|
pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
182
|
+
if (@available(iOS 10.0, *)) {
|
|
183
|
+
[UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>) self;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
//Called when a notification is delivered to a foreground app.
|
|
187
|
+
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
|
|
188
|
+
{
|
|
189
|
+
NSLog(@"User Info : %@",notification.request.content.userInfo);
|
|
190
|
+
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
|
|
194
|
+
NSDictionary *userInfo = response.notification.request.content.userInfo;
|
|
195
|
+
if (userInfo && [userInfo valueForKey:@"omisdkCallerNumber"]) {
|
|
196
|
+
NSLog(@"User Info : %@",userInfo);
|
|
197
|
+
[OmikitNotification didRecieve:userInfo];
|
|
198
|
+
}
|
|
199
|
+
completionHandler();
|
|
200
|
+
}
|
|
170
201
|
```
|
|
171
202
|
|
|
172
|
-
-
|
|
203
|
+
- Add these lines into `Info.plist`:
|
|
173
204
|
|
|
174
205
|
```
|
|
175
206
|
<key>NSMicrophoneUsageDescription</key>
|
|
@@ -191,15 +222,18 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
191
222
|
{
|
|
192
223
|
[token appendFormat:@"%02.2hhX", data[i]];
|
|
193
224
|
}
|
|
194
|
-
|
|
225
|
+
|
|
195
226
|
// print the token in the console.
|
|
196
227
|
NSLog(@"Push Notification Token: %@", [token copy]);
|
|
197
228
|
[OmiClient setUserPushNotificationToken:[token copy]];
|
|
198
229
|
}
|
|
199
230
|
|
|
200
231
|
```
|
|
232
|
+
|
|
201
233
|
*** Only use under lines when added `Cloud Messaging` plugin in your project ***
|
|
234
|
+
|
|
202
235
|
- Setup push notification: We only support Firebase for push notification.
|
|
236
|
+
|
|
203
237
|
- Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
|
|
204
238
|
- 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)
|
|
205
239
|
|
|
@@ -214,18 +248,22 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
214
248
|
//because we use APNS to push notification on iOS so you don't need add Firebase for iOS.
|
|
215
249
|
//But you can use firebase-messaging to get APNS token for iOS.
|
|
216
250
|
```
|
|
251
|
+
|
|
217
252
|
- Important function.
|
|
218
253
|
- Start Serivce: OmiKit need start services and register some events.
|
|
254
|
+
|
|
219
255
|
```
|
|
220
256
|
//Call in the root widget
|
|
221
257
|
import { startServices } from 'omikit-plugin';
|
|
222
|
-
|
|
258
|
+
|
|
223
259
|
startServices();
|
|
224
260
|
```
|
|
261
|
+
|
|
225
262
|
- 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:
|
|
263
|
+
|
|
226
264
|
```
|
|
227
265
|
import { initCallWithApiKey } from 'omikit-plugin';
|
|
228
|
-
|
|
266
|
+
|
|
229
267
|
const loginInfo = {
|
|
230
268
|
usrUuid: usrUuid,
|
|
231
269
|
fullName: fullName,
|
|
@@ -236,10 +274,12 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
236
274
|
const result = await initCallWithApiKey(loginInfo);
|
|
237
275
|
//result is true then user login successfully.
|
|
238
276
|
```
|
|
277
|
+
|
|
239
278
|
- Create OmiKit: OmiKit need userName, password, realm, host to init enviroment. ViHAT Group will provide informations for you. Please contact for my sale:
|
|
279
|
+
|
|
240
280
|
```
|
|
241
281
|
import { initCall } from 'omikit-plugin';
|
|
242
|
-
|
|
282
|
+
|
|
243
283
|
const loginInfo = {
|
|
244
284
|
userName: userName, //string
|
|
245
285
|
password: password, //string
|
|
@@ -250,38 +290,44 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
250
290
|
const result = await initCall(loginInfo);
|
|
251
291
|
//result is true then user login successfully.
|
|
252
292
|
```
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
293
|
+
|
|
294
|
+
- Config push notification:
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
import { configPushNotification } from 'omikit-plugin';
|
|
298
|
+
|
|
299
|
+
configPushNotification({
|
|
300
|
+
prefix : "Cuộc gọi tới từ: ",
|
|
301
|
+
declineTitle : "Từ chối",
|
|
302
|
+
acceptTitle : "Chấp nhận",
|
|
303
|
+
acceptBackgroundColor : "#FF3700B3",
|
|
304
|
+
declineBackgroundColor : "#FF000000",
|
|
305
|
+
incomingBackgroundColor : "#FFFFFFFF",
|
|
306
|
+
incomingAcceptButtonImage : "join_call", //image name
|
|
307
|
+
incomingDeclineButtonImage : "hangup", //image name
|
|
308
|
+
backImage : "ic_back", //image name: icon of back button
|
|
309
|
+
userImage : "calling_face", //image name: icon of user default
|
|
310
|
+
prefixMissedCallMessage: 'Cuộc gọi nhỡ từ' //config prefix message for the missed call
|
|
311
|
+
missedCallTitle: 'Cuộc gọi nhỡ' //config title for the missed call
|
|
312
|
+
});
|
|
313
|
+
//incomingAcceptButtonImage, incomingDeclineButtonImage, backImage, userImage: Add these into `android/app/src/main/res/drawble`
|
|
314
|
+
```
|
|
315
|
+
|
|
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
|
+
|
|
281
328
|
- 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
329
|
```
|
|
283
330
|
import { updateToken } from 'omikit-plugin';
|
|
284
|
-
|
|
285
331
|
const fcmToken = await fcm;
|
|
286
332
|
const apnsToken = await apns;
|
|
287
333
|
const deviceId = DeviceInfo.getDeviceId();
|
|
@@ -293,103 +339,171 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
293
339
|
appId: appId,
|
|
294
340
|
});
|
|
295
341
|
```
|
|
342
|
+
|
|
296
343
|
- Other functions:
|
|
297
|
-
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
});
|
|
314
|
-
```
|
|
344
|
+
- Call with phone number (mobile phone or internal number):
|
|
345
|
+
```
|
|
346
|
+
import {startCall} from 'omikit-plugin';
|
|
347
|
+
const result = await startCall({
|
|
348
|
+
phoneNumber: phone, //phone number
|
|
349
|
+
isVideo: false //allow video call: true/false
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
- Call with UUID (only support with Api key):
|
|
353
|
+
```
|
|
354
|
+
import {startCallWithUuid} from 'omikit-plugin';
|
|
355
|
+
const result = await startCallWithUuid({
|
|
356
|
+
usrUuid: uuid, //phone number
|
|
357
|
+
isVideo: false //allow video call: true/false
|
|
358
|
+
});
|
|
359
|
+
```
|
|
315
360
|
- Accept a call:
|
|
361
|
+
|
|
316
362
|
```
|
|
317
363
|
import {joinCall} from 'omikit-plugin';
|
|
318
|
-
|
|
364
|
+
|
|
319
365
|
await joinCall();
|
|
320
366
|
```
|
|
367
|
+
|
|
321
368
|
- End a call: We will push a event `endCall` for you.
|
|
369
|
+
|
|
322
370
|
```
|
|
323
371
|
import {endCall} from 'omikit-plugin';
|
|
324
|
-
|
|
325
|
-
await endCall();
|
|
372
|
+
|
|
373
|
+
const value = await endCall();
|
|
374
|
+
//value is call information
|
|
375
|
+
Sample output:
|
|
376
|
+
{
|
|
377
|
+
"transaction_id":ea7dff38-cb1e-483d-8576...........,
|
|
378
|
+
"direction":"inbound",
|
|
379
|
+
"source_number":111,
|
|
380
|
+
"destination_number":110,
|
|
381
|
+
"time_start_to_answer":1682858097393,
|
|
382
|
+
"time_end":1682858152181,
|
|
383
|
+
"sip_user":111,
|
|
384
|
+
"disposition":"answered"
|
|
385
|
+
}
|
|
326
386
|
```
|
|
387
|
+
|
|
327
388
|
- Toggle the audio: On/off audio a call
|
|
389
|
+
|
|
328
390
|
```
|
|
329
391
|
import {toggleMute} from 'omikit-plugin';
|
|
330
|
-
|
|
392
|
+
|
|
331
393
|
toggleMute();
|
|
332
394
|
```
|
|
395
|
+
|
|
333
396
|
- Toggle the speaker: On/off the phone speaker
|
|
397
|
+
|
|
334
398
|
```
|
|
335
399
|
import {toggleSpeaker} from 'omikit-plugin';
|
|
336
|
-
|
|
400
|
+
|
|
337
401
|
toggleSpeaker();
|
|
338
402
|
```
|
|
403
|
+
|
|
339
404
|
- Send character: We only support `1 to 9` and `* #`.
|
|
405
|
+
|
|
340
406
|
```
|
|
341
407
|
import {sendDTMF} from 'omikit-plugin';
|
|
342
|
-
|
|
408
|
+
|
|
343
409
|
sendDTMF({
|
|
344
410
|
character: text,
|
|
345
411
|
});
|
|
346
412
|
```
|
|
413
|
+
- Get current user information:
|
|
414
|
+
```
|
|
415
|
+
final user = await getCurrentUser();
|
|
416
|
+
Output Sample:
|
|
417
|
+
{
|
|
418
|
+
"extension": "111",
|
|
419
|
+
"full_name": "chau1",
|
|
420
|
+
"avatar_url": "",
|
|
421
|
+
"uuid": "122aaa"
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
- Get guest user information:
|
|
425
|
+
```
|
|
426
|
+
final user = await getGuestUser();
|
|
427
|
+
Output Sample:
|
|
428
|
+
{
|
|
429
|
+
"extension": "111",
|
|
430
|
+
"full_name": "chau1",
|
|
431
|
+
"avatar_url": "",
|
|
432
|
+
"uuid": "122aaa"
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
- Get user information from sip:
|
|
436
|
+
```
|
|
437
|
+
final user = await getUserInfo("111");
|
|
438
|
+
Output Sample:
|
|
439
|
+
{
|
|
440
|
+
"extension": "111",
|
|
441
|
+
"full_name": "chau1",
|
|
442
|
+
"avatar_url": "",
|
|
443
|
+
"uuid": "122aaa"
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
347
447
|
- Logout: Can't receive call.
|
|
448
|
+
|
|
348
449
|
```
|
|
349
450
|
import {logout} from 'omikit-plugin';
|
|
350
|
-
|
|
451
|
+
|
|
351
452
|
logout();
|
|
352
453
|
```
|
|
353
|
-
|
|
354
454
|
- Video Call functions: Support only video call, You need enable video in `init functions` and `start call` to implements under functions.
|
|
455
|
+
|
|
355
456
|
- Switch front/back camera: We use the front camera for first time.
|
|
457
|
+
|
|
356
458
|
```
|
|
357
459
|
import {switchOmiCamera} from 'omikit-plugin';
|
|
358
460
|
switchOmiCamera();
|
|
359
461
|
```
|
|
462
|
+
|
|
360
463
|
- Toggle a video in video call: On/off video in video call
|
|
464
|
+
|
|
361
465
|
```
|
|
362
466
|
import {toggleOmiVideo} from 'omikit-plugin';
|
|
363
467
|
toggleOmiVideo();
|
|
364
468
|
```
|
|
469
|
+
|
|
365
470
|
- Local Camera Widget: Your camera view in a call
|
|
471
|
+
|
|
366
472
|
```
|
|
367
473
|
import { OmiLocalCameraView } from 'omikit-plugin';
|
|
368
474
|
<OmiLocalCameraView style={styles.localCamera} />
|
|
369
475
|
```
|
|
476
|
+
|
|
370
477
|
- Remote Camera Widget: Remote camera view in a call
|
|
478
|
+
|
|
371
479
|
```
|
|
372
480
|
import { OmiRemoteCameraView } from 'omikit-plugin';
|
|
373
481
|
<OmiRemoteCameraView style={styles.remoteCamera} />
|
|
374
482
|
```
|
|
483
|
+
|
|
375
484
|
- More function: Refresh local camera
|
|
485
|
+
|
|
376
486
|
```
|
|
377
487
|
import {refreshLocalCamera} from 'omikit-plugin';
|
|
378
488
|
refreshLocalCamera();
|
|
379
489
|
```
|
|
490
|
+
|
|
380
491
|
- More function: Refresh remote camera
|
|
492
|
+
|
|
381
493
|
```
|
|
382
494
|
import {refreshRemoteCamera} from 'omikit-plugin';
|
|
383
495
|
refreshRemoteCamera();
|
|
384
496
|
```
|
|
497
|
+
|
|
385
498
|
- Register event: Register remote video ready: only visible on iOS
|
|
499
|
+
|
|
386
500
|
```
|
|
387
501
|
import {registerVideoEvent} from 'omikit-plugin';
|
|
388
502
|
registerVideoEvent();
|
|
389
503
|
```
|
|
390
504
|
|
|
391
|
-
|
|
392
505
|
- Event listener:
|
|
506
|
+
|
|
393
507
|
```
|
|
394
508
|
useEffect(() => {
|
|
395
509
|
omiEmitter.addListener(OmiCallEvent.incomingReceived, incomingReceived);
|
|
@@ -397,6 +511,7 @@ useEffect(() => {
|
|
|
397
511
|
omiEmitter.addListener(OmiCallEvent.onCallEnd, onCallEnd);
|
|
398
512
|
omiEmitter.addListener(OmiCallEvent.onMuted, onMuted);
|
|
399
513
|
omiEmitter.addListener(OmiCallEvent.onSpeaker, onSpeaker);
|
|
514
|
+
omiEmitter.addListener(OmiCallEvent.onClickMissedCall, clickMissedCall);
|
|
400
515
|
if (Platform.OS === 'ios') {
|
|
401
516
|
registerVideoEvent();
|
|
402
517
|
omiEmitter.addListener(
|
|
@@ -417,10 +532,12 @@ useEffect(() => {
|
|
|
417
532
|
};
|
|
418
533
|
}, []);
|
|
419
534
|
```
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
535
|
+
|
|
536
|
+
- Action Name value:
|
|
537
|
+
- `OmiCallEvent.incomingReceived`: Have a incoming call. On Android this event work only foreground
|
|
538
|
+
- `OmiCallEvent.onCallEstablished`: Connected a call.
|
|
539
|
+
- `OmiCallEvent.onCallEnd`: End a call and return call information (like endCall)
|
|
540
|
+
- `OmiCallEvent.onMuted`: Audio changed.
|
|
541
|
+
- `OmiCallEvent.onSpeaker`: Audio changed.
|
|
542
|
+
- `OmiCallEvent.onClickMissedCall`: Click missed call notification.
|
|
426
543
|
- 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.1.
|
|
99
|
+
api 'vn.vihat.omicall:omi-sdk:1.1.24'
|
|
100
100
|
|
|
101
101
|
implementation 'androidx.core:core-ktx:1.7.0'
|
|
102
102
|
implementation 'androidx.fragment:fragment-ktx:1.4.0'
|
|
@@ -119,6 +119,7 @@ dependencies {
|
|
|
119
119
|
implementation "com.squareup.okhttp3:okhttp:4.9.1"
|
|
120
120
|
implementation "com.squareup.okhttp3:okhttp-urlconnection:4.9.1"
|
|
121
121
|
implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
|
|
122
|
+
implementation "androidx.security:security-crypto:1.1.0-alpha06"
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
if (isNewArchitectureEnabled()) {
|
|
@@ -2,6 +2,7 @@ package com.omikitplugin
|
|
|
2
2
|
|
|
3
3
|
import android.view.Surface
|
|
4
4
|
import android.view.TextureView
|
|
5
|
+
import android.widget.LinearLayout
|
|
5
6
|
import com.facebook.react.bridge.Promise
|
|
6
7
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
8
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
@@ -13,7 +14,8 @@ import vn.vihat.omicall.omisdk.videoutils.Size
|
|
|
13
14
|
class FLLocalCameraModule(reactContext: ReactApplicationContext, localViewManager: FLLocalCameraView) :
|
|
14
15
|
ReactContextBaseJavaModule(reactContext) {
|
|
15
16
|
|
|
16
|
-
var cameraView:
|
|
17
|
+
var cameraView: LinearLayout
|
|
18
|
+
lateinit var localViewManager : FLLocalCameraView
|
|
17
19
|
|
|
18
20
|
override fun getName(): String {
|
|
19
21
|
return "FLLocalCameraView"
|
|
@@ -21,17 +23,12 @@ class FLLocalCameraModule(reactContext: ReactApplicationContext, localViewManage
|
|
|
21
23
|
|
|
22
24
|
init {
|
|
23
25
|
cameraView = localViewManager.localView
|
|
26
|
+
this.localViewManager = localViewManager
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
@ReactMethod
|
|
27
30
|
fun refresh(promise: Promise) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ScaleManager.adjustAspectRatio(cameraView,
|
|
31
|
-
Size(cameraView.width, cameraView.height),
|
|
32
|
-
Size(1280,720)
|
|
33
|
-
)
|
|
34
|
-
promise.resolve(true)
|
|
35
|
-
}
|
|
31
|
+
this.localViewManager.refreshTexture()
|
|
32
|
+
promise.resolve(true)
|
|
36
33
|
}
|
|
37
34
|
}
|
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
package com.omikitplugin
|
|
2
2
|
|
|
3
|
+
import android.view.Surface
|
|
3
4
|
import android.view.TextureView
|
|
5
|
+
import android.widget.LinearLayout
|
|
4
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
7
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
|
+
import vn.vihat.omicall.omisdk.OmiClient
|
|
10
|
+
import vn.vihat.omicall.omisdk.videoutils.ScaleManager
|
|
11
|
+
import vn.vihat.omicall.omisdk.videoutils.Size
|
|
7
12
|
|
|
8
13
|
class FLLocalCameraView(private val context: ReactApplicationContext) :
|
|
9
|
-
SimpleViewManager<
|
|
10
|
-
val localView :
|
|
14
|
+
SimpleViewManager<LinearLayout>() {
|
|
15
|
+
val localView : LinearLayout = LinearLayout(context)
|
|
16
|
+
private val cameraView : TextureView = TextureView(context)
|
|
17
|
+
|
|
18
|
+
init {
|
|
19
|
+
localView.addView(cameraView)
|
|
20
|
+
}
|
|
11
21
|
|
|
12
22
|
override fun getName(): String {
|
|
13
23
|
return "FLLocalCameraView"
|
|
14
24
|
}
|
|
15
25
|
|
|
16
|
-
override fun createViewInstance(p0: ThemedReactContext):
|
|
26
|
+
override fun createViewInstance(p0: ThemedReactContext): LinearLayout {
|
|
17
27
|
return localView
|
|
18
28
|
}
|
|
19
29
|
|
|
20
|
-
fun localViewInstance():
|
|
30
|
+
fun localViewInstance(): LinearLayout {
|
|
21
31
|
return localView
|
|
22
32
|
}
|
|
33
|
+
|
|
34
|
+
fun refreshTexture() {
|
|
35
|
+
cameraView.surfaceTexture?.let {
|
|
36
|
+
OmiClient.instance.setupLocalVideoFeed(Surface(it))
|
|
37
|
+
ScaleManager.adjustAspectRatio(
|
|
38
|
+
cameraView,
|
|
39
|
+
Size(cameraView.width, cameraView.height),
|
|
40
|
+
Size(1280, 720)
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
23
44
|
}
|