omikit-plugin 0.1.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 (31) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +31 -0
  3. package/android/build.gradle +134 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +190 -0
  7. package/android/src/main/java/com/omikitplugin/OmikitPluginPackage.kt +17 -0
  8. package/android/src/main/java/com/omikitplugin/constants/constant.kt +31 -0
  9. package/ios/CallProcess/CallManager.swift +367 -0
  10. package/ios/CallProcess/NSUserActivity.swift +58 -0
  11. package/ios/CallProcess/StringUtils.swift +18 -0
  12. package/ios/Constant/Constant.swift +47 -0
  13. package/ios/OmikitPlugin-Bridging-Header.h +2 -0
  14. package/ios/OmikitPlugin.m +17 -0
  15. package/ios/OmikitPlugin.swift +19 -0
  16. package/ios/OmikitPlugin.xcodeproj/project.pbxproj +321 -0
  17. package/ios/OmikitPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  18. package/ios/OmikitPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  19. package/ios/OmikitPlugin.xcodeproj/project.xcworkspace/xcuserdata/pro201916.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  20. package/ios/OmikitPlugin.xcodeproj/xcuserdata/pro201916.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  21. package/ios/VideoCall/FLLocalCameraView.swift +81 -0
  22. package/ios/VideoCall/FLRemoteCameraView.swift +84 -0
  23. package/lib/commonjs/index.js +58 -0
  24. package/lib/commonjs/index.js.map +1 -0
  25. package/lib/module/index.js +42 -0
  26. package/lib/module/index.js.map +1 -0
  27. package/lib/typescript/index.d.ts +12 -0
  28. package/lib/typescript/index.d.ts.map +1 -0
  29. package/omikit-plugin.podspec +36 -0
  30. package/package.json +166 -0
  31. package/src/index.tsx +59 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 ViHAT Group
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # omikit-plugin
2
+
3
+ Audio and Video call
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install omikit-plugin
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import { multiply } from 'omikit-plugin';
15
+
16
+ // ...
17
+
18
+ const result = await multiply(3, 7);
19
+ ```
20
+
21
+ ## Contributing
22
+
23
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
24
+
25
+ ## License
26
+
27
+ MIT
28
+
29
+ ---
30
+
31
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,134 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["OmikitPlugin_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ maven {
9
+ url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
10
+ credentials {
11
+ username = "downloader"
12
+ password = "Omi@2022"
13
+ }
14
+ }
15
+ }
16
+
17
+ dependencies {
18
+ classpath "com.android.tools.build:gradle:7.2.1"
19
+ // noinspection DifferentKotlinGradleVersion
20
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
21
+ classpath 'com.google.dagger:hilt-android-gradle-plugin:2.39.1'
22
+ classpath 'com.github.kezong:fat-aar:1.3.8'
23
+ classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.29.3"
24
+ }
25
+ }
26
+
27
+ def isNewArchitectureEnabled() {
28
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
29
+ }
30
+
31
+ apply plugin: "com.android.library"
32
+ apply plugin: "kotlin-android"
33
+ apply plugin: 'kotlin-kapt'
34
+ apply plugin: 'kotlin-parcelize'
35
+
36
+ if (isNewArchitectureEnabled()) {
37
+ apply plugin: "com.facebook.react"
38
+ }
39
+
40
+ def getExtOrDefault(name) {
41
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["OmikitPlugin_" + name]
42
+ }
43
+
44
+ def getExtOrIntegerDefault(name) {
45
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["OmikitPlugin_" + name]).toInteger()
46
+ }
47
+
48
+ android {
49
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
50
+
51
+ defaultConfig {
52
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
53
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
54
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
55
+ }
56
+ buildTypes {
57
+ release {
58
+ minifyEnabled false
59
+ }
60
+ }
61
+
62
+ lintOptions {
63
+ disable "GradleCompatible"
64
+ }
65
+
66
+ compileOptions {
67
+ sourceCompatibility JavaVersion.VERSION_1_8
68
+ targetCompatibility JavaVersion.VERSION_1_8
69
+ }
70
+
71
+ }
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
+ allprojects {
87
+ repositories {
88
+ google()
89
+ mavenCentral()
90
+ jcenter() // Warning: this repository is going to shut down soon
91
+ maven {
92
+ url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
93
+ credentials {
94
+ username = "downloader"
95
+ password = "Omi@2022"
96
+ }
97
+ }
98
+ }
99
+ }
100
+
101
+
102
+ def kotlin_version = getExtOrDefault("kotlinVersion")
103
+
104
+ dependencies {
105
+ // For < 0.71, this will be from the local maven repo
106
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
107
+ //noinspection GradleDynamicVersion
108
+ implementation "com.facebook.react:react-native"
109
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
110
+
111
+ api 'vn.vihat.omicall:omi-sdk:0.9.12'
112
+
113
+ implementation 'androidx.core:core-ktx:1.7.0'
114
+ implementation 'androidx.fragment:fragment-ktx:1.4.0'
115
+ implementation 'androidx.activity:activity-ktx:1.4.0'
116
+ implementation 'androidx.appcompat:appcompat:1.5.0'
117
+ implementation 'com.google.android.material:material:1.6.1'
118
+ implementation 'com.google.firebase:firebase-messaging-ktx:23.0.8'
119
+ implementation 'com.google.android.flexbox:flexbox:3.0.0'
120
+ implementation "com.google.code.gson:gson:2.8.6"
121
+ def lifecycle_version = "2.4.0"
122
+ implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
123
+ implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
124
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
125
+ implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
126
+ }
127
+
128
+ if (isNewArchitectureEnabled()) {
129
+ react {
130
+ jsRootDir = file("../src/")
131
+ libraryName = "OmikitPlugin"
132
+ codegenJavaPackageName = "com.omikitplugin"
133
+ }
134
+ }
@@ -0,0 +1,5 @@
1
+ OmikitPlugin_kotlinVersion=1.7.10
2
+ OmikitPlugin_minSdkVersion=21
3
+ OmikitPlugin_targetSdkVersion=33
4
+ OmikitPlugin_compileSdkVersion=33
5
+ OmikitPlugin_ndkversion=21.4.7075529
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.omikitplugin">
3
+
4
+ </manifest>
@@ -0,0 +1,190 @@
1
+ package com.omikitplugin
2
+
3
+ import android.Manifest
4
+ import androidx.core.app.ActivityCompat
5
+ import com.facebook.react.ReactActivity
6
+ import com.facebook.react.bridge.*
7
+ import com.facebook.react.modules.core.RCTNativeAppEventEmitter
8
+ import vn.vihat.omicall.omisdk.OmiClient
9
+ import vn.vihat.omicall.omisdk.OmiListener
10
+ import vn.vihat.omicall.omisdk.OmiSDKUtils
11
+
12
+
13
+ class OmikitPluginModule(reactContext: ReactApplicationContext) :
14
+ ReactContextBaseJavaModule(reactContext), OmiListener {
15
+
16
+ override fun getName(): String {
17
+ return NAME
18
+ }
19
+
20
+
21
+ @ReactMethod
22
+ fun initCall(data: ReadableMap, promise: Promise) {
23
+ val userName = data.getString("userName") as String
24
+ val password = data.getString("password") as String
25
+ val realm = data.getString("realm") as String
26
+ OmiClient.register(reactApplicationContext!!, userName, password, realm)
27
+ ActivityCompat.requestPermissions(
28
+ currentActivity!!,
29
+ arrayOf(
30
+ Manifest.permission.USE_SIP,
31
+ Manifest.permission.CALL_PHONE,
32
+ Manifest.permission.CAMERA,
33
+ Manifest.permission.MODIFY_AUDIO_SETTINGS,
34
+ Manifest.permission.RECORD_AUDIO,
35
+ ),
36
+ 0,
37
+ )
38
+ OmiClient.instance.setListener(this)
39
+ promise.resolve(true)
40
+ }
41
+
42
+ @ReactMethod
43
+ fun updateToken(data: ReadableMap, promise: Promise) {
44
+ val deviceTokenAndroid = data.getString("fcmToken") as String
45
+ val appId = data.getString("appId") as String
46
+ val deviceId = data.getString("deviceId") as String
47
+ OmiClient.instance.updatePushToken(
48
+ "",
49
+ deviceTokenAndroid,
50
+ deviceId,
51
+ appId
52
+ )
53
+ promise.resolve(true)
54
+ }
55
+
56
+
57
+ @ReactMethod
58
+ fun startCall(data: ReadableMap, promise: Promise) {
59
+ val phoneNumber = data.getString("phoneNumber") as String
60
+ val isVideo = data.getBoolean("isVideo")
61
+ if (!isVideo) {
62
+ OmiClient.instance.startCall(phoneNumber)
63
+ promise.resolve(true)
64
+ }
65
+ }
66
+
67
+ @ReactMethod
68
+ fun endCall(promise: Promise) {
69
+ OmiClient.instance.hangUp()
70
+ promise.resolve(true)
71
+ }
72
+
73
+ @ReactMethod
74
+ fun toggleMute(promise: Promise) {
75
+ OmiClient.instance.toggleMute()
76
+ promise.resolve(true)
77
+ }
78
+
79
+ @ReactMethod
80
+ fun toggleSpeak(data: ReadableMap, promise: Promise) {
81
+ val useSpeaker = data.getBoolean("useSpeaker")
82
+ OmiClient.instance.toggleSpeaker(useSpeaker)
83
+ promise.resolve(true)
84
+ }
85
+
86
+ @ReactMethod
87
+ fun decline(promise: Promise) {
88
+ OmiClient.instance.decline()
89
+ promise.resolve(true)
90
+ }
91
+
92
+ @ReactMethod
93
+ fun hangup(data: ReadableMap, promise: Promise) {
94
+ val callId = data.getInt("callId")
95
+ OmiClient.instance.hangUp(callId)
96
+ promise.resolve(true)
97
+ }
98
+
99
+
100
+ @ReactMethod
101
+ fun onCallStart(data: ReadableMap, promise: Promise) {
102
+ val callId = data.getInt("callId")
103
+ OmiClient.instance.onCallStarted(callId)
104
+ promise.resolve(true)
105
+ }
106
+
107
+ @ReactMethod
108
+ fun onHold(data: ReadableMap, promise: Promise) {
109
+ val isHold = data.getBoolean("isHold")
110
+ OmiClient.instance.onHold(isHold)
111
+ promise.resolve(true)
112
+ }
113
+
114
+ @ReactMethod
115
+ fun onMute(data: ReadableMap, promise: Promise) {
116
+ val isMute = data.getBoolean("isMute")
117
+ OmiClient.instance.onMuted(isMute)
118
+ promise.resolve(true)
119
+ }
120
+
121
+ @ReactMethod
122
+ fun sendDTMF(data: ReadableMap, promise: Promise) {
123
+ val character = data.getString("character")
124
+ var characterCode: Int? = character?.toIntOrNull()
125
+ if (character == "*") {
126
+ characterCode = 10
127
+ }
128
+ if (character == "#") {
129
+ characterCode = 11
130
+ }
131
+ if (characterCode != null) {
132
+ OmiClient.instance.sendDtmf(characterCode)
133
+ }
134
+ promise.resolve(true)
135
+ }
136
+
137
+ companion object {
138
+ const val NAME = "OmikitPlugin"
139
+ fun onDestroy() {
140
+ OmiClient.instance.disconnect()
141
+ }
142
+
143
+ fun onRequestPermissionsResult(
144
+ requestCode: Int,
145
+ permissions: Array<out String>,
146
+ grantResults: IntArray,
147
+ act: ReactActivity,
148
+ ) {
149
+ OmiSDKUtils.handlePermissionRequest(requestCode, permissions, grantResults, act)
150
+ }
151
+ }
152
+
153
+ override fun incomingReceived(callerId: Int, phoneNumber: String?) {
154
+ sendEvent("incomingReceived", mapOf(
155
+ "callerId" to callerId,
156
+ "phoneNumber" to phoneNumber,
157
+ ))
158
+ }
159
+
160
+ override fun onCallEnd() {
161
+ sendEvent("onCallEnd", false)
162
+ }
163
+
164
+ override fun onCallEstablished() {
165
+ sendEvent("onCallEstablished", null)
166
+ }
167
+
168
+ override fun onConnectionTimeout() {
169
+ sendEvent("onConnectionTimeout", null)
170
+ }
171
+
172
+ override fun onHold(isHold: Boolean) {
173
+
174
+ }
175
+
176
+ override fun onMuted(isMuted: Boolean) {
177
+ sendEvent("onMuted", mapOf(
178
+ "isMuted" to isMuted,
179
+ ))
180
+ }
181
+
182
+ override fun onRinging() {
183
+ sendEvent("onRinging", null)
184
+ }
185
+
186
+ private fun sendEvent(eventName: String?, params: Any?) {
187
+ reactApplicationContext.getJSModule(RCTNativeAppEventEmitter::class.java)
188
+ .emit(eventName, params)
189
+ }
190
+ }
@@ -0,0 +1,17 @@
1
+ package com.omikitplugin
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+
9
+ class OmikitPluginPackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return listOf(OmikitPluginModule(reactContext))
12
+ }
13
+
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
+ return emptyList()
16
+ }
17
+ }
@@ -0,0 +1,31 @@
1
+ package com.omikitplugin.constants
2
+
3
+ //EVENT
4
+ const val INIT_CALL = "INIT_CALL";
5
+ const val UPDATE_TOKEN = "UPDATE_TOKEN";
6
+ const val START_OMI_SERVICE = "START_OMI_SERVICE";
7
+ const val START_CALL = "START_CALL";
8
+ const val END_CALL = "END_CALL";
9
+ const val TOGGLE_MUTE = "TOGGLE_MUTE";
10
+ const val TOGGLE_SPEAK = "TOGGLE_SPEAK";
11
+ const val CHECK_ON_GOING_CALL = "CHECK_ON_GOING_CALL";
12
+ const val DECLINE = "DECLINE";
13
+ const val FORWARD_CALL_TO = "FORWARD_CALL_TO";
14
+ const val HANGUP = "HANGUP";
15
+ const val ON_CALL_STARTED = "ON_CALL_STARTED";
16
+ const val ON_HOLD = "ON_HOLD";
17
+ const val ON_IN_COMING_RECEIVE = "ON_IN_COMING_RECEIVE";
18
+ const val ON_MUTE = "ON_MUTE";
19
+ const val ON_OUT_GOING = "ON_OUT_GOING";
20
+ const val REGISTER = "REGISTER";
21
+ const val SEND_DTMF = "SEND_DTMF";
22
+
23
+ //LISTENER
24
+ const val onCallEstablished = "CALL_ESTABLISHED"
25
+ const val onCallEnd = "CALL_END"
26
+ const val incomingReceived = "INCOMING_RECEIVED"
27
+ const val onRinging = "RINGING"
28
+ const val onConnectionTimeout = "CONNECTION_TIMEOUT"
29
+ const val onHold = "HOLD"
30
+ const val onMuted = "MUTED"
31
+