omikit-plugin 1.0.1 → 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 +99 -15
- 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
|
@@ -101,7 +101,6 @@ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blo
|
|
|
101
101
|
//add this lines outside <activity>
|
|
102
102
|
<service
|
|
103
103
|
android:name="vn.vihat.omicall.omisdk.service.FMService"
|
|
104
|
-
android:enabled="true"
|
|
105
104
|
android:exported="false">
|
|
106
105
|
<intent-filter>
|
|
107
106
|
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
@@ -216,6 +215,27 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
216
215
|
//But you can use firebase-messaging to get APNS token for iOS.
|
|
217
216
|
```
|
|
218
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
|
+
```
|
|
219
239
|
- Create OmiKit: OmiKit need userName, password, realm, host to init enviroment. ViHAT Group will provide informations for you. Please contact for my sale:
|
|
220
240
|
```
|
|
221
241
|
import { initCall } from 'omikit-plugin';
|
|
@@ -228,7 +248,36 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
228
248
|
host: host, //string
|
|
229
249
|
};
|
|
230
250
|
const result = await initCall(loginInfo);
|
|
251
|
+
//result is true then user login successfully.
|
|
231
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
|
+
```
|
|
232
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>
|
|
233
282
|
```
|
|
234
283
|
import { updateToken } from 'omikit-plugin';
|
|
@@ -274,9 +323,9 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
274
323
|
```
|
|
275
324
|
- Toggle the speaker: On/off the phone speaker
|
|
276
325
|
```
|
|
277
|
-
import {
|
|
326
|
+
import {toggleSpeaker} from 'omikit-plugin';
|
|
278
327
|
|
|
279
|
-
|
|
328
|
+
toggleSpeaker();
|
|
280
329
|
```
|
|
281
330
|
- Send character: We only support `1 to 9` and `* #`.
|
|
282
331
|
```
|
|
@@ -286,26 +335,61 @@ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
|
|
|
286
335
|
character: text,
|
|
287
336
|
});
|
|
288
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
|
+
```
|
|
289
370
|
|
|
290
|
-
- Event listener:
|
|
291
371
|
|
|
372
|
+
- Event listener:
|
|
292
373
|
```
|
|
293
374
|
useEffect(() => {
|
|
294
|
-
omiEmitter.addListener(
|
|
295
|
-
omiEmitter.addListener(
|
|
296
|
-
omiEmitter.addListener(
|
|
297
|
-
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);
|
|
298
380
|
return () => {
|
|
299
|
-
omiEmitter.removeAllListeners(
|
|
381
|
+
omiEmitter.removeAllListeners(OmiCallEvent.incomingReceived);
|
|
300
382
|
omiEmitter.removeAllListeners('onCallEstablished');
|
|
301
|
-
omiEmitter.removeAllListeners(
|
|
302
|
-
omiEmitter.removeAllListeners(
|
|
383
|
+
omiEmitter.removeAllListeners(OmiCallEvent.onCallEnd);
|
|
384
|
+
omiEmitter.removeAllListeners(OmiCallEvent.onMuted);
|
|
385
|
+
omiEmitter.removeAllListeners(OmiCallEvent.onSpeaker);
|
|
303
386
|
};
|
|
304
387
|
}, []);
|
|
305
388
|
```
|
|
306
389
|
- 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.
|
|
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.
|
|
311
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
|
+
}
|