omikit-plugin 3.3.7 → 3.3.9
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
CHANGED
|
@@ -570,6 +570,7 @@ We support 2 environments. So you need set correct key in Appdelegate.
|
|
|
570
570
|
```
|
|
571
571
|
-Android:
|
|
572
572
|
+ PERMISSIONS.ANDROID.RECORD_AUDIO
|
|
573
|
+
+ PERMISSIONS.ANDROID.POST_NOTIFICATIONS
|
|
573
574
|
+ PERMISSIONS.ANDROID.CALL_PHONE
|
|
574
575
|
+ PERMISSIONS.ANDROID.CAMERA; (if you want to make Video calls)
|
|
575
576
|
|
|
@@ -579,60 +580,34 @@ We support 2 environments. So you need set correct key in Appdelegate.
|
|
|
579
580
|
|
|
580
581
|
```
|
|
581
582
|
|
|
582
|
-
### 🔥 **Android
|
|
583
|
+
### 🔥 **Android Permission Management**
|
|
583
584
|
|
|
584
|
-
**📌 For Android
|
|
585
|
+
**📌 For Android (SDK), additional permissions are required:**
|
|
586
|
+
|
|
587
|
+
🔥 Notes:
|
|
588
|
+
|
|
589
|
+
• POST_NOTIFICATIONS and RECORD_AUDIO must be requested at runtime in your code.
|
|
590
|
+
|
|
591
|
+
• FOREGROUND_SERVICE* permissions only need to be declared in the manifest; Android will enforce them automatically when you call startForegroundService().
|
|
585
592
|
|
|
586
593
|
```xml
|
|
587
|
-
<!--
|
|
594
|
+
<!-- Runtime permissions -->
|
|
588
595
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
596
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
597
|
+
|
|
598
|
+
<!-- Foreground service permissions (manifest only, no runtime request needed) -->
|
|
599
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
|
589
600
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
|
|
590
601
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL"/>
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
**📌 Built-in Permission Functions:**
|
|
594
|
-
|
|
595
|
-
✅ **checkPermissionStatus()** - Check current permission status:
|
|
596
|
-
```javascript
|
|
597
|
-
import { checkPermissionStatus } from 'omikit-plugin';
|
|
598
|
-
|
|
599
|
-
const permissionStatus = await checkPermissionStatus();
|
|
600
|
-
console.log(permissionStatus);
|
|
601
|
-
// Output: { essentialGranted: [...], essentialMissing: [...], canMakeVoipCalls: true/false }
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
✅ **checkAndRequestPermissions()** - Request all necessary permissions:
|
|
605
|
-
```javascript
|
|
606
|
-
import { checkAndRequestPermissions } from 'omikit-plugin';
|
|
607
|
-
|
|
608
|
-
const isVideo = true; // Set to true if video call permissions needed
|
|
609
|
-
const permissionsGranted = await checkAndRequestPermissions(isVideo);
|
|
610
|
-
if (permissionsGranted) {
|
|
611
|
-
console.log('All permissions granted!');
|
|
612
|
-
}
|
|
613
|
-
```
|
|
602
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" tools:node="remove" />
|
|
614
603
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const result = await requestPermissionsByCodes(codes);
|
|
622
|
-
|
|
623
|
-
/*
|
|
624
|
-
Permission Code Mapping:
|
|
625
|
-
- 450: RECORD_AUDIO permission (Android 14+)
|
|
626
|
-
- 451: FOREGROUND_SERVICE permissions (Android 14+)
|
|
627
|
-
- 452: POST_NOTIFICATIONS permission (Android 13+)
|
|
628
|
-
*/
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
**📌 System Alert Window Permission:**
|
|
632
|
-
```javascript
|
|
633
|
-
import { requestSystemAlertWindowPermission } from 'omikit-plugin';
|
|
604
|
+
<service
|
|
605
|
+
android:name="net.gotev.sipservice.SipService"
|
|
606
|
+
android:foregroundServiceType="phoneCall|microphone"
|
|
607
|
+
tools:replace="android:foregroundServiceType"
|
|
608
|
+
android:exported="false"
|
|
609
|
+
/>
|
|
634
610
|
|
|
635
|
-
const canDrawOverlays = await requestSystemAlertWindowPermission();
|
|
636
611
|
```
|
|
637
612
|
|
|
638
613
|
- ✅ Set up <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> plugin:
|
|
@@ -666,6 +641,69 @@ startServices();
|
|
|
666
641
|
|
|
667
642
|
*Add the following code to the root file of your application, such as `App.js` or `index.js`*
|
|
668
643
|
|
|
644
|
+
|
|
645
|
+
📌 **requestLoginPermissions()**
|
|
646
|
+
|
|
647
|
+
`Note`: Starting from Android 13+, certain foreground services (such as microphone or phone call) require explicit user permission before they can be started.
|
|
648
|
+
This means the user must grant these permissions before initiating a call or any service that relies on them.
|
|
649
|
+
|
|
650
|
+
```TypeScript
|
|
651
|
+
import {
|
|
652
|
+
PERMISSIONS,
|
|
653
|
+
request,
|
|
654
|
+
check,
|
|
655
|
+
RESULTS,
|
|
656
|
+
requestMultiple
|
|
657
|
+
} from 'react-native-permissions';
|
|
658
|
+
import { Platform } from 'react-native';
|
|
659
|
+
|
|
660
|
+
export async function requestLoginPermissions(): Promise<boolean> {
|
|
661
|
+
if (Platform.OS !== 'android') return true;
|
|
662
|
+
|
|
663
|
+
const permissions: string[] = [];
|
|
664
|
+
|
|
665
|
+
// Android 13+ cần POST_NOTIFICATIONS
|
|
666
|
+
if (Platform.Version >= 33) {
|
|
667
|
+
permissions.push(PERMISSIONS.ANDROID.POST_NOTIFICATIONS);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// Android 14+ và 15+ cần RECORD_AUDIO trước khi start foreground service
|
|
671
|
+
permissions.push(PERMISSIONS.ANDROID.RECORD_AUDIO);
|
|
672
|
+
|
|
673
|
+
const statuses = await requestMultiple(permissions);
|
|
674
|
+
|
|
675
|
+
// Check kết quả
|
|
676
|
+
const allGranted = Object.values(statuses).every(
|
|
677
|
+
status => status === RESULTS.GRANTED
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
if (!allGranted) {
|
|
681
|
+
console.warn('❌ Some required permissions were not granted');
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
console.log('✅ All required permissions granted');
|
|
686
|
+
return true;
|
|
687
|
+
}
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
Example: use func `requestLoginPermissions()`
|
|
691
|
+
|
|
692
|
+
```TypeScript
|
|
693
|
+
async function handleLogin() {
|
|
694
|
+
const ok = await requestLoginPermissions();
|
|
695
|
+
if (!ok) {
|
|
696
|
+
// Block login, show alert
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// ✅ Safe để start service login
|
|
701
|
+
// initCallWithApiKey();
|
|
702
|
+
initCallWithUserPassword()
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
|
|
669
707
|
📌 **initCallWithApiKey()**
|
|
670
708
|
|
|
671
709
|
📝 Notes: The information below is taken from the API, you should connect with our Technical team for support
|
|
@@ -745,65 +783,52 @@ const loginInfo = {
|
|
|
745
783
|
};
|
|
746
784
|
|
|
747
785
|
// Initialize call functionality using username and password authentication
|
|
748
|
-
|
|
786
|
+
initCallWithUserPassword(loginInfo)
|
|
787
|
+
.then(result => {
|
|
788
|
+
console.log('initCallWithUserPassword success:', result);
|
|
749
789
|
|
|
750
|
-
|
|
751
|
-
|
|
790
|
+
if (result) {
|
|
791
|
+
// ✅ Login OMI Success
|
|
792
|
+
/* ❌ ❌ NOTE: Please check the user information again, if the object is not empty then you have successfully logged in.
|
|
752
793
|
Otherwise, if you have not successfully logged in, you should not navigate to the call screen. When startCall with empty information, it may crash your application or not be clear when receiving the startCall error ❌❌*/
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
const loginInfo = {
|
|
793
|
-
userName: "your_username",
|
|
794
|
-
password: "your_password",
|
|
795
|
-
realm: "your_realm",
|
|
796
|
-
isVideo: true,
|
|
797
|
-
fcmToken: "your_fcm_token",
|
|
798
|
-
projectId: "your_project_id",
|
|
799
|
-
showNotification: false, // Control notification display
|
|
800
|
-
enableAutoUnregister: false // Control auto-unregister behavior
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
const result = await registerWithOptions(loginInfo);
|
|
804
|
-
console.log(result);
|
|
805
|
-
// Output: { success: true/false, statusCode: number, message: string }
|
|
806
|
-
```
|
|
794
|
+
const infoUser = await getCurrentUser()
|
|
795
|
+
if (infoUser != null && Object.keys(infoUser).length > 0) {
|
|
796
|
+
// ✅ Login OMI Success
|
|
797
|
+
// Can navigate to call screen or start call 🚀 🚀
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
})
|
|
801
|
+
.catch(error => {
|
|
802
|
+
// You can log error and check cause error
|
|
803
|
+
console.error('initCallWithUserPassword error:', error?.code, error?.message);
|
|
804
|
+
if (error?.code === 'ERROR_MISSING_RECORD_AUDIO') { // Please request permission audio
|
|
805
|
+
requestPermission();
|
|
806
|
+
}
|
|
807
|
+
})
|
|
808
|
+
.finally(() => {
|
|
809
|
+
// Doing something
|
|
810
|
+
// setLoading(false);
|
|
811
|
+
});
|
|
812
|
+
```
|
|
813
|
+
📝 **Detailed Description of Possible Errors(error?.code)**
|
|
814
|
+
|
|
815
|
+
| **Message** | **Description** | **Next Action** |
|
|
816
|
+
|------------------------------------|---------------------------------------------------------------------------------|----------------------------
|
|
817
|
+
| `ERROR_MISSING_PARAMETERS` | Missing required parameters. Please check your configuration. | Verify all required fields are provided |
|
|
818
|
+
| `ERROR_INVALID_CREDENTIALS` | Invalid credentials. Please check username/password. | Double-check login info |
|
|
819
|
+
| `ERROR_FORBIDDEN` | Access denied. Check realm/domain permissions. | Confirm account permissions with provider |
|
|
820
|
+
| `ERROR_REALM_NOT_FOUND` | Realm not found. Check configuration. | Ensure realm/domain is correct |
|
|
821
|
+
| `ERROR_TIMEOUT` | Connection timeout | Retry with stable network |
|
|
822
|
+
| `ERROR_MISSING_RECORD_AUDIO` | RECORD_AUDIO permission required for Android 14+ | Ask user to grant microphone permission |
|
|
823
|
+
| `ERROR_MISSING_FOREGROUND_SERVICE` | FOREGROUND_SERVICE permission required | Request foreground service permission before starting service |
|
|
824
|
+
| `ERROR_MISSING_POST_NOTIFICATIONS` | POST_NOTIFICATIONS permission required for Android 13+ | Request notification permission before registering |
|
|
825
|
+
| `ERROR_SERVICE_START_FAILED` | Failed to start SIP service | Check logs and required permissions |
|
|
826
|
+
| `ERROR_SERVICE_NOT_AVAILABLE` | SIP service not available | Ensure service is running |
|
|
827
|
+
| `ERROR_SERVICE_DEGRADED` | Service degraded - may miss calls when app killed | Keep app in foreground or request proper permissions |
|
|
828
|
+
| `ERROR_SERVICE_UNAVAILABLE` | Service temporarily unavailable | Try again later |
|
|
829
|
+
| `ERROR_NETWORK_UNAVAILABLE` | Network unavailable | Check network connection |
|
|
830
|
+
| `ERROR_CONNECTION_TIMEOUT` | Connection timeout | Verify network and server availability |
|
|
831
|
+
| `ERROR_UNKNOWN` | Unknown error occurred | Check logs and report issue |
|
|
807
832
|
|
|
808
833
|
📌 **configPushNotification()**
|
|
809
834
|
|
|
@@ -825,8 +850,8 @@ configPushNotification({
|
|
|
825
850
|
missedCallTitle: "Cuộc gọi nhỡ", // Title for missed call notifications
|
|
826
851
|
userNameKey: "uuid", // User identification key: options are "uuid", "full_name", or "extension"
|
|
827
852
|
channelId: "com.channel.sample", // Custom notification channel ID for Android
|
|
828
|
-
audioNotificationDescription: "", // Description for audio call notifications
|
|
829
|
-
videoNotificationDescription: "", // Description for video call notifications
|
|
853
|
+
audioNotificationDescription: "Cuộc gọi audio", // Description for audio call notifications
|
|
854
|
+
videoNotificationDescription: "Cuộc gọi video", // Description for video call notifications
|
|
830
855
|
representName: "", // Representative name to display for all incoming calls (e.g., business name)
|
|
831
856
|
isUserBusy: true // By default, it is set to true. The Omicall system will continue ringing the next user if isUserBusy is true. If it is false, the call will be immediately terminated, assuming the call scenario is based on a criteria-based routing.
|
|
832
857
|
});
|
|
@@ -1111,39 +1136,6 @@ const result = await startCallWithUuid({
|
|
|
1111
1136
|
logout();
|
|
1112
1137
|
```
|
|
1113
1138
|
|
|
1114
|
-
📌 **hideSystemNotificationSafely()** *(OmiSDK 2.3.67+)*
|
|
1115
|
-
|
|
1116
|
-
✅ Description: Safely hide system notification and unregister after a delay.
|
|
1117
|
-
|
|
1118
|
-
```javascript
|
|
1119
|
-
import { hideSystemNotificationSafely } from 'omikit-plugin';
|
|
1120
|
-
|
|
1121
|
-
const success = await hideSystemNotificationSafely();
|
|
1122
|
-
// Hides notification and unregisters after 2 seconds
|
|
1123
|
-
```
|
|
1124
|
-
|
|
1125
|
-
📌 **hideSystemNotificationOnly()** *(OmiSDK 2.3.67+)*
|
|
1126
|
-
|
|
1127
|
-
✅ Description: Hide system notification only, without unregistering.
|
|
1128
|
-
|
|
1129
|
-
```javascript
|
|
1130
|
-
import { hideSystemNotificationOnly } from 'omikit-plugin';
|
|
1131
|
-
|
|
1132
|
-
const success = await hideSystemNotificationOnly();
|
|
1133
|
-
// Keeps registration active but hides notification
|
|
1134
|
-
```
|
|
1135
|
-
|
|
1136
|
-
📌 **hideSystemNotificationAndUnregister()** *(OmiSDK 2.3.67+)*
|
|
1137
|
-
|
|
1138
|
-
✅ Description: Hide notification and unregister with custom reason.
|
|
1139
|
-
|
|
1140
|
-
```javascript
|
|
1141
|
-
import { hideSystemNotificationAndUnregister } from 'omikit-plugin';
|
|
1142
|
-
|
|
1143
|
-
const success = await hideSystemNotificationAndUnregister("User logout");
|
|
1144
|
-
// Hides notification and unregisters immediately with reason
|
|
1145
|
-
```
|
|
1146
|
-
|
|
1147
1139
|
📌 **systemAlertWindow()**
|
|
1148
1140
|
|
|
1149
1141
|
✅ Description: Check system alert window permission (only Android).
|
|
@@ -1281,7 +1273,10 @@ useEffect(() => {
|
|
|
1281
1273
|
omiEmitter.addListener(OmiCallEvent.onClickMissedCall, clickMissedCall);
|
|
1282
1274
|
omiEmitter.addListener(OmiCallEvent.onSwitchboardAnswer, onSwitchboardAnswer);
|
|
1283
1275
|
omiEmitter.addListener(OmiCallEvent.onCallQuality, onCallQuality);
|
|
1284
|
-
|
|
1276
|
+
|
|
1277
|
+
omiEmitter.addListener(OmiCallEvent.onAudioChange, onAudioChange);
|
|
1278
|
+
|
|
1279
|
+
|
|
1285
1280
|
if(Platform.OS == "android") {
|
|
1286
1281
|
omiEmitter.addListener(OmiCallEvent.onRequestPermissionAndroid, onRequestPermission);
|
|
1287
1282
|
}
|
|
@@ -1300,7 +1295,8 @@ useEffect(() => {
|
|
|
1300
1295
|
omiEmitter.removeAllListeners(OmiCallEvent.onHold);
|
|
1301
1296
|
omiEmitter.removeAllListeners(OmiCallEvent.onSpeaker);
|
|
1302
1297
|
omiEmitter.removeAllListeners(OmiCallEvent.onSwitchboardAnswer);
|
|
1303
|
-
|
|
1298
|
+
omiEmitter.removeAllListeners(OmiCallEvent.onAudioChange);
|
|
1299
|
+
|
|
1304
1300
|
if(Platform.OS == "android") {
|
|
1305
1301
|
omiEmitter.removeAllListeners(OmiCallEvent.onRequestPermissionAndroid);
|
|
1306
1302
|
}
|
|
@@ -1394,6 +1390,12 @@ const onSwitchboardAnswer = (data: any) => {
|
|
|
1394
1390
|
const { sip } = data
|
|
1395
1391
|
// sip: String
|
|
1396
1392
|
}
|
|
1393
|
+
|
|
1394
|
+
// * onAudioChange have callback when the user switches the audio output device (headphones)
|
|
1395
|
+
const onAudioChange = (audioData: any) => {
|
|
1396
|
+
const { data } = audioData;
|
|
1397
|
+
|
|
1398
|
+
}
|
|
1397
1399
|
```
|
|
1398
1400
|
|
|
1399
1401
|
✨ Table describing `code_end_call, codeEndCall` status
|
|
@@ -1428,34 +1430,6 @@ const onSwitchboardAnswer = (data: any) => {
|
|
|
1428
1430
|
| `864` | Temporary block on Mobifone direction, please try again |
|
|
1429
1431
|
| `865` | he advertising number is currently outside the permitted calling hours, please try again later |
|
|
1430
1432
|
|
|
1431
|
-
# 🔥 Android 15+ Compatibility Features
|
|
1432
|
-
|
|
1433
|
-
## ✨ New in Version 3.3.5+
|
|
1434
|
-
|
|
1435
|
-
### **Enhanced Permission Management**
|
|
1436
|
-
- **Full Android 15 (SDK 35+) Support**: Automatic handling of new foreground service permissions
|
|
1437
|
-
- **Smart Permission Requests**: Built-in functions to request specific permissions by error codes
|
|
1438
|
-
- **Comprehensive Status Checking**: Real-time permission status monitoring
|
|
1439
|
-
- **Version-Aware Logic**: Automatically handles Android version differences
|
|
1440
|
-
|
|
1441
|
-
### **Advanced Registration Options** *(OmiSDK 2.3.67+)*
|
|
1442
|
-
- **Silent Registration**: Register without notifications or auto-unregister
|
|
1443
|
-
- **Credential Validation**: Check login credentials without connecting
|
|
1444
|
-
- **Custom Registration**: Full control over notification and unregister behavior
|
|
1445
|
-
- **Notification Management**: Fine-grained control over system notifications
|
|
1446
|
-
|
|
1447
|
-
### **Error Code Mapping**
|
|
1448
|
-
Complete mapping of OmiSDK status codes to user-friendly error messages:
|
|
1449
|
-
- **450**: RECORD_AUDIO permission required for Android 14+
|
|
1450
|
-
- **451**: FOREGROUND_SERVICE permission required
|
|
1451
|
-
- **452**: POST_NOTIFICATIONS permission required for Android 13+
|
|
1452
|
-
- **500-600**: Service and network error handling
|
|
1453
|
-
- **Detailed Messages**: Customer-friendly error descriptions for easier integration
|
|
1454
|
-
|
|
1455
|
-
### **Development Workflow**
|
|
1456
|
-
- **copy_dev.sh**: Efficient development workflow for testing native code changes
|
|
1457
|
-
- **Automatic Build Fixes**: Handles gradle namespace issues automatically
|
|
1458
|
-
- **Hot Reload**: Quick testing without npm publishing
|
|
1459
1433
|
|
|
1460
1434
|
### **Breaking Changes**
|
|
1461
1435
|
- **Android 15+ Support**: Requires additional permissions in AndroidManifest.xml
|
package/android/build.gradle
CHANGED
|
@@ -122,7 +122,7 @@ dependencies {
|
|
|
122
122
|
implementation("androidx.work:work-runtime:2.8.1")
|
|
123
123
|
implementation "androidx.security:security-crypto:1.1.0-alpha06"
|
|
124
124
|
// api 'vn.vihat.omicall:omi-sdk:2.3.23'
|
|
125
|
-
api "io.omicrm.vihat:omi-sdk:2.3.
|
|
125
|
+
api "io.omicrm.vihat:omi-sdk:2.3.90"
|
|
126
126
|
|
|
127
127
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
128
128
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
@@ -412,15 +412,8 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
// ✅ Helper function
|
|
416
|
-
|
|
417
|
-
try {
|
|
418
|
-
Log.w("OmikitPlugin", "⚠️ DEPRECATED: preventAutoUnregisterCrash() - Use Silent Registration API instead")
|
|
419
|
-
OmiClient.getInstance(reactApplicationContext!!).preventAutoUnregister(reason)
|
|
420
|
-
} catch (e: Exception) {
|
|
421
|
-
Log.e("OmikitPlugin", "❌ Failed to prevent AUTO-UNREGISTER: ${e.message}", e)
|
|
422
|
-
}
|
|
423
|
-
}
|
|
415
|
+
// ✅ Helper function removed - deprecated in new SDK version
|
|
416
|
+
// preventAutoUnregisterCrash is no longer supported
|
|
424
417
|
|
|
425
418
|
// ✅ Method để check status AUTO-UNREGISTER (DEPRECATED)
|
|
426
419
|
@ReactMethod
|
|
@@ -449,14 +442,9 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
449
442
|
// ✅ Method để manually prevent AUTO-UNREGISTER (DEPRECATED)
|
|
450
443
|
@ReactMethod
|
|
451
444
|
fun preventAutoUnregister(reason: String, promise: Promise) {
|
|
452
|
-
Log.w("OmikitPlugin", "⚠️ DEPRECATED: preventAutoUnregister() -
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
promise.resolve(true)
|
|
456
|
-
} catch (e: Exception) {
|
|
457
|
-
Log.e("OmikitPlugin", "❌ Manual prevent failed: ${e.message}", e)
|
|
458
|
-
promise.resolve(false)
|
|
459
|
-
}
|
|
445
|
+
Log.w("OmikitPlugin", "⚠️ DEPRECATED: preventAutoUnregister() - No longer supported in new SDK version")
|
|
446
|
+
// Function removed - no longer supported
|
|
447
|
+
promise.resolve(false)
|
|
460
448
|
}
|
|
461
449
|
|
|
462
450
|
// ✅ Convenience methods cho các scenario phổ biến (DEPRECATED)
|
|
@@ -723,20 +711,27 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
723
711
|
"fcmToken" to firebaseToken
|
|
724
712
|
), promise)) return@withContext
|
|
725
713
|
|
|
714
|
+
// ✅ Cleanup trước khi register
|
|
715
|
+
try {
|
|
716
|
+
OmiClient.getInstance(reactApplicationContext!!).logout()
|
|
717
|
+
delay(500) // Chờ cleanup hoàn tất
|
|
718
|
+
} catch (e: Exception) {
|
|
719
|
+
Log.w("OmikitPlugin", "⚠️ Cleanup warning (expected): ${e.message}")
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
Log.d("OmikitPlugin", "🔑 Using API key registration for user: $usrName")
|
|
723
|
+
|
|
726
724
|
loginResult = OmiClient.registerWithApiKey(
|
|
727
|
-
apiKey
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
isVideo
|
|
732
|
-
firebaseToken
|
|
733
|
-
projectId
|
|
725
|
+
apiKey ?: "",
|
|
726
|
+
usrName ?: "",
|
|
727
|
+
phone ?: "",
|
|
728
|
+
usrUuid ?: "",
|
|
729
|
+
isVideo,
|
|
730
|
+
firebaseToken
|
|
734
731
|
)
|
|
735
732
|
|
|
736
|
-
// ✅ Sử dụng API mới để ngăn chặn AUTO-UNREGISTER sau khi register thành công
|
|
737
733
|
if (loginResult) {
|
|
738
|
-
Log.d("OmikitPlugin", "
|
|
739
|
-
preventAutoUnregisterCrash("Successful API key registration - userName: $usrName")
|
|
734
|
+
Log.d("OmikitPlugin", "✅ API key registration successful")
|
|
740
735
|
promise.resolve(true)
|
|
741
736
|
} else {
|
|
742
737
|
Log.e("OmikitPlugin", "❌ API key registration failed")
|
|
@@ -855,6 +850,7 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
855
850
|
reactApplicationContext!!,
|
|
856
851
|
Manifest.permission.RECORD_AUDIO
|
|
857
852
|
)
|
|
853
|
+
val map: WritableMap = WritableNativeMap()
|
|
858
854
|
if (audio == PackageManager.PERMISSION_GRANTED) {
|
|
859
855
|
mainScope.launch {
|
|
860
856
|
var callResult: OmiStartCallStatus? = null
|
|
@@ -869,10 +865,17 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
869
865
|
|
|
870
866
|
}
|
|
871
867
|
}
|
|
872
|
-
|
|
868
|
+
var statusCalltemp = callResult?.ordinal ?: 7
|
|
869
|
+
map.putInt("status", statusCalltemp)
|
|
870
|
+
map.putString("_id", "")
|
|
871
|
+
map.putString("message", messageCall(statusCalltemp) as String)
|
|
872
|
+
promise.resolve(map)
|
|
873
873
|
}
|
|
874
874
|
} else {
|
|
875
|
-
|
|
875
|
+
map.putInt("status", 4)
|
|
876
|
+
map.putString("_id", "")
|
|
877
|
+
map.putString("message", messageCall(406) as String)
|
|
878
|
+
promise.resolve(map)
|
|
876
879
|
}
|
|
877
880
|
}
|
|
878
881
|
|
|
@@ -1585,10 +1588,10 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
1585
1588
|
// ✅ Thêm listener cho AUTO-UNREGISTER status
|
|
1586
1589
|
private val autoUnregisterListener = object : OmiListener {
|
|
1587
1590
|
override fun onAutoUnregisterStatus(isScheduled: Boolean, timeUntilExecution: Long) {
|
|
1588
|
-
// ✅
|
|
1591
|
+
// ✅ Auto-unregister prevention removed - no longer supported in new SDK
|
|
1589
1592
|
if (isScheduled && timeUntilExecution > 0 && timeUntilExecution < 3000) {
|
|
1590
|
-
Log.w("OmikitPlugin", "🚨 AUTO-UNREGISTER sắp thực hiện trong ${timeUntilExecution}ms -
|
|
1591
|
-
preventAutoUnregisterCrash
|
|
1593
|
+
Log.w("OmikitPlugin", "🚨 AUTO-UNREGISTER sắp thực hiện trong ${timeUntilExecution}ms - SDK tự xử lý")
|
|
1594
|
+
// preventAutoUnregisterCrash deprecated - SDK handles automatically
|
|
1592
1595
|
}
|
|
1593
1596
|
|
|
1594
1597
|
// ✅ Gửi event cho React Native
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omikit-plugin",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.9",
|
|
4
4
|
"description": "Omikit Plugin by ViHAT",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">= 16.0.0"
|
|
80
80
|
},
|
|
81
|
-
"packageManager": "
|
|
81
|
+
"packageManager": "yarn@1.22.15",
|
|
82
82
|
"jest": {
|
|
83
83
|
"preset": "react-native",
|
|
84
84
|
"modulePathIgnorePatterns": [
|