omikit-plugin 4.1.4 → 4.1.6

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/LICENSE CHANGED
@@ -1,20 +1,22 @@
1
- MIT License
1
+ OMICALL SDK License
2
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:
3
+ Copyright (c) 2022-2026 ViHAT Group (VIHAT JSC). All rights reserved.
10
4
 
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
5
+ This SDK is provided exclusively for customers of the OMICALL platform
6
+ (https://omicall.com). By using this SDK, you agree to the following terms:
7
+
8
+ PERMITTED:
9
+ - Use the SDK to integrate OMICALL services into your applications
10
+ - Include the SDK in applications distributed to your end users
11
+
12
+ PROHIBITED:
13
+ - Use the SDK without an active OMICALL account or subscription
14
+ - Redistribute, sublicense, or sell the SDK as a standalone product
15
+ - Use the SDK to build competing communication platforms
16
+ - Reverse engineer, decompile, or disassemble the SDK
13
17
 
14
18
  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.
19
+ IMPLIED. IN NO EVENT SHALL VIHAT GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY ARISING FROM THE USE OF THIS SOFTWARE.
21
+
22
+ Contact: support@omicall.com
package/README.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # OMICALL SDK for React Native
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/omikit-plugin.svg)](https://www.npmjs.com/package/omikit-plugin)
4
+ [![npm downloads](https://img.shields.io/npm/dm/omikit-plugin.svg)](https://www.npmjs.com/package/omikit-plugin)
5
+ [![license](https://img.shields.io/badge/license-proprietary-red.svg)](./LICENSE)
6
+
7
+ ```bash
8
+ npm install omikit-plugin
9
+ ```
10
+
3
11
  The [omikit-plugin](https://www.npmjs.com/package/omikit-plugin) enables VoIP/SIP calling via the OMICALL platform with support for both Old and **New Architecture** (TurboModules + Fabric).
4
12
 
5
- **Status:** Active maintenance | **Version:** 4.1.4
13
+ > **⚠️ Expo is not supported.** This SDK requires native modules (SIP/VoIP, CallKit, PushKit) that are not compatible with Expo managed workflow. Please use React Native CLI.
6
14
 
7
15
  ---
8
16
 
@@ -33,8 +41,8 @@ The [omikit-plugin](https://www.npmjs.com/package/omikit-plugin) enables VoIP/SI
33
41
 
34
42
  | omikit-plugin | React Native | Architecture | Installation |
35
43
  |---------------|--------------|--------------|--------------|
36
- | **4.0.x** (latest) | 0.74+ | Old + New (auto-detect) | `npm install omikit-plugin@latest` |
37
- | 3.3.x | 0.60 – 0.73 | Old Architecture only | `npm install omikit-plugin@3.3.29` |
44
+ | **4.x** (latest) | 0.74+ | Old + New (auto-detect) | `npm install omikit-plugin` |
45
+ | 3.3.x (legacy) | 0.60 – 0.73 | Old Architecture only | `npm install omikit-plugin@3.3.29` |
38
46
 
39
47
  **v4.0.x highlights:**
40
48
  - **TurboModules (JSI)** — 4-10x faster native method calls via direct C++ bridge
@@ -1154,88 +1154,57 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
1154
1154
  @ReactMethod
1155
1155
  fun getCurrentUser(promise: Promise) {
1156
1156
  mainScope.launch {
1157
- var callResult: Any? = null
1158
- withContext(Dispatchers.Default) {
1157
+ val callResult = withContext(Dispatchers.Default) {
1159
1158
  try {
1160
- val omiClient = OmiClient.getInstance(reactApplicationContext!!)
1161
- callResult = omiClient.getCurrentUser()
1162
- } catch (e: Throwable) {
1163
- Log.e("OmikitPlugin", "❌ getCurrentUser error: ${e.message}", e)
1159
+ OmiClient.getInstance(reactApplicationContext!!).getCurrentUser()
1160
+ } catch (_: Throwable) {
1161
+ null
1164
1162
  }
1165
1163
  }
1166
- if (callResult != null && callResult is Map<*, *>) {
1167
- val call = callResult as Map<*, *>
1168
- val map: WritableMap = WritableNativeMap()
1169
- map.putString("extension", call["extension"] as String?)
1170
- map.putString("uuid", call["uuid"] as String?)
1171
- map.putString("full_name", call["full_name"] as String?)
1172
- map.putString("avatar_url", call["avatar_url"] as String?)
1173
-
1174
- map.putString("fullName", call["full_name"] as String?)
1175
- map.putString("avatarUrl", call["avatar_url"] as String?)
1164
+ resolveUserResult(callResult, promise)
1165
+ }
1166
+ }
1176
1167
 
1177
- Log.d("OmikitPlugin", "✅ getCurrentUser resolved: extension=${call["extension"]}, uuid=${call["uuid"]}, full_name=${call["full_name"]}")
1178
- promise.resolve(map)
1179
- } else {
1180
- Log.w("OmikitPlugin", "⚠️ getCurrentUser resolved NULL — callResult=$callResult, isMap=${callResult is Map<*, *>}")
1181
- promise.resolve(null);
1182
- }
1168
+ private fun resolveUserResult(callResult: Any?, promise: Promise) {
1169
+ if (callResult is Map<*, *>) {
1170
+ val map: WritableMap = WritableNativeMap()
1171
+ map.putString("extension", callResult["extension"] as String?)
1172
+ map.putString("uuid", callResult["uuid"] as String?)
1173
+ map.putString("full_name", callResult["full_name"] as String?)
1174
+ map.putString("avatar_url", callResult["avatar_url"] as String?)
1175
+ map.putString("fullName", callResult["full_name"] as String?)
1176
+ map.putString("avatarUrl", callResult["avatar_url"] as String?)
1177
+ promise.resolve(map)
1178
+ } else {
1179
+ promise.resolve(null)
1183
1180
  }
1184
1181
  }
1185
1182
 
1186
1183
  @ReactMethod
1187
1184
  fun getGuestUser(promise: Promise) {
1188
1185
  mainScope.launch {
1189
- var callResult: Any? = null
1190
- withContext(Dispatchers.Default) {
1186
+ val callResult = withContext(Dispatchers.Default) {
1191
1187
  try {
1192
- callResult = OmiClient.getInstance(reactApplicationContext!!).getIncomingCallUser()
1188
+ OmiClient.getInstance(reactApplicationContext!!).getIncomingCallUser()
1193
1189
  } catch (_: Throwable) {
1194
-
1190
+ null
1195
1191
  }
1196
1192
  }
1197
- if (callResult != null && callResult is Map<*, *>) {
1198
- val call = callResult as Map<*, *>
1199
- val map: WritableMap = WritableNativeMap()
1200
- map.putString("extension", call["extension"] as String?)
1201
- map.putString("uuid", call["uuid"] as String?)
1202
- map.putString("full_name", call["full_name"] as String?)
1203
- map.putString("avatar_url", call["avatar_url"] as String?)
1204
-
1205
- map.putString("fullName", call["full_name"] as String?)
1206
- map.putString("avatarUrl", call["avatar_url"] as String?)
1207
-
1208
- promise.resolve(map)
1209
- } else {
1210
- promise.resolve(null);
1211
- }
1193
+ resolveUserResult(callResult, promise)
1212
1194
  }
1213
1195
  }
1214
1196
 
1215
1197
  @ReactMethod
1216
1198
  fun getUserInfo(phone: String, promise: Promise) {
1217
1199
  mainScope.launch {
1218
- var callResult: Any? = null
1219
- withContext(Dispatchers.Default) {
1200
+ val callResult = withContext(Dispatchers.Default) {
1220
1201
  try {
1221
- callResult = OmiClient.getInstance(reactApplicationContext!!).getUserInfo(phone)
1202
+ OmiClient.getInstance(reactApplicationContext!!).getUserInfo(phone)
1222
1203
  } catch (_: Throwable) {
1204
+ null
1223
1205
  }
1224
1206
  }
1225
- if (callResult != null && callResult is Map<*, *>) {
1226
- val call = callResult as Map<*, *>
1227
- val map: WritableMap = WritableNativeMap()
1228
- map.putString("extension", call["extension"] as String?)
1229
- map.putString("uuid", call["uuid"] as String?)
1230
- map.putString("full_name", call["full_name"] as String?)
1231
- map.putString("avatar_url", call["avatar_url"] as String?)
1232
-
1233
- map.putString("fullName", call["full_name"] as String?)
1234
- map.putString("avatarUrl", call["avatar_url"] as String?)
1235
- promise.resolve(map)
1236
- } else {
1237
- promise.resolve(null)
1238
- }
1207
+ resolveUserResult(callResult, promise)
1239
1208
  }
1240
1209
  }
1241
1210
 
@@ -394,9 +394,27 @@ class CallManager {
394
394
  }
395
395
 
396
396
  @objc func callDealloc(_ notification: NSNotification) {
397
- if (tempCallInfo != nil) {
398
- tempCallInfo!["status"] = OMICallState.disconnected.rawValue
399
- OmikitPlugin.instance?.sendEvent(withName: CALL_STATE_CHANGED, body: tempCallInfo!)
397
+ // Extract endCause from OMICallDealloc notification — this is the reliable source
398
+ // for the SIP end code (486=busy, 603=decline, 408=timeout, etc.)
399
+ let endCause = notification.userInfo?[OMINotificationEndCauseKey] as? Int
400
+
401
+ if var info = tempCallInfo, !info.isEmpty {
402
+ info["status"] = OMICallState.disconnected.rawValue
403
+ if let endCause = endCause {
404
+ info["code_end_call"] = endCause
405
+ info["codeEndCall"] = endCause
406
+ }
407
+ OmikitPlugin.instance?.sendEvent(withName: CALL_STATE_CHANGED, body: info)
408
+ tempCallInfo = [:]
409
+ } else if let endCause = endCause {
410
+ // No tempCallInfo (callStateChanged fired first and cleared it),
411
+ // but we still have an endCause — send minimal event so JS gets the code
412
+ let fallback: [String: Any] = [
413
+ "status": OMICallState.disconnected.rawValue,
414
+ "code_end_call": endCause,
415
+ "codeEndCall": endCause
416
+ ]
417
+ OmikitPlugin.instance?.sendEvent(withName: CALL_STATE_CHANGED, body: fallback)
400
418
  }
401
419
  }
402
420
 
@@ -457,7 +475,7 @@ class CallManager {
457
475
  }
458
476
  OmikitPlugin.instance?.sendEvent(withName: CALL_STATE_CHANGED, body: combinedDictionary )
459
477
  lastTimeCall = Date()
460
- tempCallInfo = [:]
478
+ // Keep tempCallInfo for callDealloc — it will clear after use
461
479
  break
462
480
  default:
463
481
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omikit-plugin",
3
- "version": "4.1.4",
3
+ "version": "4.1.6",
4
4
  "description": "Omikit Plugin by ViHAT",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -46,7 +46,7 @@
46
46
  "url": "git+https://github.com/VIHATTeam/OMICALL-React-Native-SDK"
47
47
  },
48
48
  "author": "ViHAT Group <tranhoaihung05@gmail.com>",
49
- "license": "MIT",
49
+ "license": "SEE LICENSE IN LICENSE",
50
50
  "bugs": {
51
51
  "url": "https://github.com/VIHATTeam/OMICALL-React-Native-SDK/issues"
52
52
  },