omikit-plugin 3.3.28 → 4.0.1

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 (49) hide show
  1. package/README.md +949 -1223
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/omikitplugin/FLLocalCameraModule.kt +1 -1
  4. package/android/src/main/java/com/omikitplugin/FLRemoteCameraModule.kt +1 -1
  5. package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +277 -325
  6. package/android/src/main/java/com/omikitplugin/constants/constant.kt +2 -1
  7. package/ios/CallProcess/CallManager.swift +45 -35
  8. package/ios/Constant/Constant.swift +1 -0
  9. package/ios/Library/OmikitPlugin.m +75 -1
  10. package/ios/Library/OmikitPlugin.swift +199 -16
  11. package/ios/OmikitPlugin-Protocol.h +161 -0
  12. package/lib/commonjs/NativeOmikitPlugin.js +9 -0
  13. package/lib/commonjs/NativeOmikitPlugin.js.map +1 -0
  14. package/lib/commonjs/index.js +11 -0
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/omi_audio_type.js +20 -0
  17. package/lib/commonjs/omi_audio_type.js.map +1 -0
  18. package/lib/commonjs/omi_local_camera.js +12 -2
  19. package/lib/commonjs/omi_local_camera.js.map +1 -1
  20. package/lib/commonjs/omi_remote_camera.js +12 -2
  21. package/lib/commonjs/omi_remote_camera.js.map +1 -1
  22. package/lib/commonjs/omi_start_call_status.js +30 -0
  23. package/lib/commonjs/omi_start_call_status.js.map +1 -1
  24. package/lib/commonjs/omikit.js +110 -16
  25. package/lib/commonjs/omikit.js.map +1 -1
  26. package/lib/module/NativeOmikitPlugin.js +3 -0
  27. package/lib/module/NativeOmikitPlugin.js.map +1 -0
  28. package/lib/module/index.js +1 -0
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/omi_audio_type.js +14 -0
  31. package/lib/module/omi_audio_type.js.map +1 -0
  32. package/lib/module/omi_local_camera.js +13 -2
  33. package/lib/module/omi_local_camera.js.map +1 -1
  34. package/lib/module/omi_remote_camera.js +13 -2
  35. package/lib/module/omi_remote_camera.js.map +1 -1
  36. package/lib/module/omi_start_call_status.js +30 -0
  37. package/lib/module/omi_start_call_status.js.map +1 -1
  38. package/lib/module/omikit.js +104 -17
  39. package/lib/module/omikit.js.map +1 -1
  40. package/omikit-plugin.podspec +26 -24
  41. package/package.json +11 -2
  42. package/src/NativeOmikitPlugin.ts +160 -0
  43. package/src/index.tsx +2 -1
  44. package/src/omi_audio_type.tsx +9 -0
  45. package/src/omi_local_camera.tsx +12 -3
  46. package/src/omi_remote_camera.tsx +12 -3
  47. package/src/omi_start_call_status.tsx +29 -10
  48. package/src/omikit.tsx +96 -19
  49. package/src/types/index.d.ts +111 -11
@@ -1,11 +1,20 @@
1
1
  import type { HostComponent } from 'react-native';
2
2
  import { NativeModules, requireNativeComponent, ViewProps } from 'react-native';
3
3
 
4
- const FLRemoteCamera = NativeModules.FLRemoteCameraView;
4
+ // Camera Views always use Paper (requireNativeComponent) because:
5
+ // - iOS native code doesn't have Fabric ComponentView implementation yet
6
+ // - Paper components work fine even when New Architecture is enabled
7
+ // - This avoids undefined symbol errors (_FLRemoteCameraViewCls)
8
+ const OmiRemoteCameraViewPaper: HostComponent<ViewProps> = requireNativeComponent(
9
+ 'FLRemoteCameraView'
10
+ );
5
11
 
6
- export const OmiRemoteCameraView: HostComponent<ViewProps> =
7
- requireNativeComponent('FLRemoteCameraView');
12
+ // Export the Paper component
13
+ export const OmiRemoteCameraView: HostComponent<ViewProps> = OmiRemoteCameraViewPaper;
8
14
 
15
+ // Module name separated from ViewManager name to avoid name collision
16
+ const FLRemoteCamera = NativeModules.FLRemoteCameraModule || NativeModules.FLRemoteCameraView;
9
17
  export function refreshRemoteCamera(): Promise<boolean> {
18
+ if (!FLRemoteCamera) return Promise.resolve(false);
10
19
  return FLRemoteCamera.refresh();
11
20
  }
@@ -1,12 +1,31 @@
1
+ /**
2
+ * Status codes returned by startCall() function
3
+ * Use these to handle different call initiation results
4
+ */
1
5
  export enum OmiStartCallStatus {
2
- invalidUuid = 0,
3
- invalidPhoneNumber = 1,
4
- samePhoneNumber = 2,
5
- maxRetry = 3,
6
- permissionDenied = 4,
7
- couldNotFindEndpoint = 5,
8
- accountRegisterFailed = 6,
9
- startCallFailed = 7,
10
- startCallSuccess = 8,
11
- haveAnotherCall = 9,
6
+ // Validation errors (0-3)
7
+ invalidUuid = 0, // Invalid user UUID
8
+ invalidPhoneNumber = 1, // Invalid phone number format
9
+ samePhoneNumber = 2, // Cannot call same phone number
10
+ maxRetry = 3, // Maximum retry attempts reached
11
+
12
+ // Permission errors (4, 450-452)
13
+ permissionDenied = 4, // Microphone/Camera permission denied
14
+ permissionMicrophone = 450, // Microphone permission required (Android 15+)
15
+ permissionCamera = 451, // Camera permission required (Android 15+)
16
+ permissionOverlay = 452, // System alert window permission required (Android 15+)
17
+
18
+ // Call errors (5-7)
19
+ couldNotFindEndpoint = 5, // Could not find endpoint
20
+ accountRegisterFailed = 6, // Account registration failed
21
+ startCallFailed = 7, // Start call failed
22
+
23
+ // Success statuses (8, 407)
24
+ startCallSuccess = 8, // Call initiated successfully (Android)
25
+ startCallSuccessIOS = 407, // Call initiated successfully (iOS)
26
+
27
+ // Other errors (9+)
28
+ haveAnotherCall = 9, // Already have another call in progress
29
+ accountTurnOffNumberInternal = 10, // Internal number has been deactivated
30
+ noNetwork = 11, // No network connection available
12
31
  }
package/src/omikit.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import { NativeModules, Platform, NativeEventEmitter, DeviceEventEmitter } from 'react-native';
1
+ import { NativeModules, Platform, NativeEventEmitter, DeviceEventEmitter, TurboModuleRegistry } from 'react-native';
2
+ import type { Spec } from './NativeOmikitPlugin';
2
3
 
3
4
  const LINKING_ERROR =
4
5
  `The package 'omikit-plugin' doesn't seem to be linked. Make sure: \n\n` +
@@ -6,10 +7,20 @@ const LINKING_ERROR =
6
7
  '- You rebuilt the app after installing the package\n' +
7
8
  '- You are not using Expo Go\n';
8
9
 
9
- // Khai báo chính xác Native Module
10
- const OmikitPlugin = NativeModules.OmikitPlugin
11
- ? NativeModules.OmikitPlugin
12
- : new Proxy(
10
+ // Runtime detection: Try TurboModule first, fallback to NativeModule
11
+ const isTurboModuleEnabled = (global as any).__turboModuleProxy != null;
12
+
13
+ const OmikitPlugin: Spec = (() => {
14
+ if (isTurboModuleEnabled) {
15
+ // New Architecture - use TurboModule
16
+ const turboModule = TurboModuleRegistry.get<Spec>('OmikitPlugin');
17
+ if (turboModule) {
18
+ return turboModule;
19
+ }
20
+ }
21
+
22
+ // Old Architecture - fallback to NativeModule
23
+ return NativeModules.OmikitPlugin || new Proxy(
13
24
  {},
14
25
  {
15
26
  get() {
@@ -17,10 +28,17 @@ const OmikitPlugin = NativeModules.OmikitPlugin
17
28
  },
18
29
  }
19
30
  );
31
+ })();
20
32
 
21
- // Setup omiEmitter cho iOS Android
33
+ // Setup omiEmitter for iOS and Android
34
+ // In bridgeless mode, NativeModules is empty — use TurboModule instance instead
22
35
  const omiEmitter = Platform.OS === 'ios'
23
- ? new NativeEventEmitter(OmikitPlugin)
36
+ ? new NativeEventEmitter(
37
+ (NativeModules.OmikitPlugin ?? OmikitPlugin ?? {
38
+ addListener: () => {},
39
+ removeListeners: () => {},
40
+ }) as any
41
+ )
24
42
  : DeviceEventEmitter;
25
43
 
26
44
  /**
@@ -41,14 +59,14 @@ export function configPushNotification(data: any): Promise<any> {
41
59
  }
42
60
 
43
61
  /**
44
- * Retrieves the initial call details when start call
62
+ * Retrieves the initial call details when start call
45
63
  * @returns {Promise<any>} A promise containing the initial call details.
46
64
  */
47
65
  export function getInitialCall(): Promise<any> {
48
66
  if (Platform.OS == "ios") {
49
- return OmikitPlugin.getInitialCall();
67
+ return OmikitPlugin.getInitialCall({ counter: 0 });
50
68
  } else {
51
- return OmikitPlugin.getInitialCall(4);
69
+ return OmikitPlugin.getInitialCall({ counter: 4 });
52
70
  }
53
71
  }
54
72
 
@@ -73,9 +91,9 @@ export function initCallWithApiKey(data: any): Promise<boolean> {
73
91
  /**
74
92
  * Starts a new call with the given data.
75
93
  * @param {any} data - Call configuration data.
76
- * @returns {Promise<boolean>} A promise that resolves to `true` if the call starts successfully.
94
+ * @returns {Promise<any>} A promise that resolves with call details if successful.
77
95
  */
78
- export function startCall(data: any): Promise<boolean> {
96
+ export function startCall(data: any): Promise<any> {
79
97
  return OmikitPlugin.startCall(data);
80
98
  }
81
99
 
@@ -106,9 +124,9 @@ export function endCall(): Promise<any> {
106
124
 
107
125
  /**
108
126
  * Toggles the mute status of the microphone.
109
- * @returns {Promise<boolean>} A promise that resolves to `true` if the microphone is muted, `false` otherwise.
127
+ * @returns {Promise<boolean | null>} A promise that resolves to `true` if the microphone is muted, `false` otherwise, or `null` if unavailable.
110
128
  */
111
- export function toggleMute(): Promise<boolean> {
129
+ export function toggleMute(): Promise<boolean | null> {
112
130
  return OmikitPlugin.toggleMute();
113
131
  }
114
132
 
@@ -122,9 +140,9 @@ export function toggleSpeaker(): Promise<boolean> {
122
140
 
123
141
  /**
124
142
  * Toggles the hold call.
125
- * @returns {Promise<boolean>} A promise that resolves to `true` if when hold call success, `false` otherwise.
143
+ * @returns {Promise<void>} A promise that resolves when hold call is toggled.
126
144
  */
127
- export function toggleHold(): Promise<boolean> {
145
+ export function toggleHold(): Promise<void> {
128
146
  return OmikitPlugin.toggleHold();
129
147
  }
130
148
 
@@ -282,7 +300,7 @@ export function hideSystemNotificationOnly(): Promise<boolean> {
282
300
  }
283
301
 
284
302
  export function hideSystemNotificationAndUnregister(reason: string): Promise<boolean> {
285
- return OmikitPlugin.hideSystemNotificationAndUnregister(reason);
303
+ return OmikitPlugin.hideSystemNotificationAndUnregister({ reason });
286
304
  }
287
305
 
288
306
  export const OmiCallEvent = {
@@ -338,7 +356,7 @@ export function checkAndRequestPermissions(isVideo: boolean = false): Promise<bo
338
356
  if (Platform.OS !== 'android') {
339
357
  return Promise.resolve(true);
340
358
  }
341
- return OmikitPlugin.checkAndRequestPermissions(isVideo);
359
+ return OmikitPlugin.checkAndRequestPermissions({ isVideo });
342
360
  }
343
361
 
344
362
  /**
@@ -362,6 +380,65 @@ export function requestPermissionsByCodes(codes: number[]): Promise<boolean> {
362
380
  if (Platform.OS !== 'android') {
363
381
  return Promise.resolve(true);
364
382
  }
365
- return OmikitPlugin.requestPermissionsByCodes(codes);
383
+ return OmikitPlugin.requestPermissionsByCodes({ codes });
384
+ }
385
+
386
+ // MARK: - Getter Functions
387
+
388
+ /**
389
+ * Retrieves user info by phone number.
390
+ * @param {string} phone - The phone number to look up.
391
+ * @returns {Promise<any>} User info object or null.
392
+ */
393
+ export function getUserInfo(phone: string): Promise<any> {
394
+ return OmikitPlugin.getUserInfo({ phone });
395
+ }
396
+
397
+ /**
398
+ * Retrieves the project ID from OmiClient.
399
+ * @returns {Promise<string | null>} The project ID or null.
400
+ */
401
+ export function getProjectId(): Promise<string | null> {
402
+ return OmikitPlugin.getProjectId();
403
+ }
404
+
405
+ /**
406
+ * Retrieves SIP connection info (user@realm).
407
+ * @returns {Promise<string | null>} SIP info string or null.
408
+ */
409
+ export function getSipInfo(): Promise<string | null> {
410
+ return OmikitPlugin.getSipInfo();
411
+ }
412
+
413
+ /**
414
+ * Retrieves the app ID from OmiClient.
415
+ * @returns {Promise<string | null>} The app ID or null.
416
+ */
417
+ export function getAppId(): Promise<string | null> {
418
+ return OmikitPlugin.getAppId();
419
+ }
420
+
421
+ /**
422
+ * Retrieves the device ID from OmiClient.
423
+ * @returns {Promise<string | null>} The device ID or null.
424
+ */
425
+ export function getDeviceId(): Promise<string | null> {
426
+ return OmikitPlugin.getDeviceId();
427
+ }
428
+
429
+ /**
430
+ * Retrieves the FCM token from OmiClient.
431
+ * @returns {Promise<string | null>} The FCM token or null.
432
+ */
433
+ export function getFcmToken(): Promise<string | null> {
434
+ return OmikitPlugin.getFcmToken();
435
+ }
436
+
437
+ /**
438
+ * Retrieves the VoIP token (iOS only, Android returns null).
439
+ * @returns {Promise<string | null>} The VoIP token or null.
440
+ */
441
+ export function getVoipToken(): Promise<string | null> {
442
+ return OmikitPlugin.getVoipToken();
366
443
  }
367
444
 
@@ -1,12 +1,30 @@
1
1
  declare module 'omikit-plugin' {
2
2
  import { NativeEventEmitter } from 'react-native';
3
3
 
4
+ // ============================================
5
+ // FUNCTIONS
6
+ // ============================================
7
+
4
8
  export function startServices(): Promise<any>;
5
9
  export function configPushNotification(data: any): Promise<any>;
6
10
  export function getInitialCall(): Promise<any>;
7
11
  export function initCallWithUserPassword(data: any): Promise<boolean>;
8
12
  export function initCallWithApiKey(data: any): Promise<boolean>;
9
- export function startCall(data: any): Promise<boolean>;
13
+
14
+ /**
15
+ * Starts a new call
16
+ * @param data - Call configuration { phoneNumber: string, isVideo: boolean }
17
+ * @returns Promise with call result { status: OmiStartCallStatus, message?: string, _id?: string }
18
+ */
19
+ export function startCall(data: {
20
+ phoneNumber: string;
21
+ isVideo: boolean;
22
+ }): Promise<{
23
+ status: OmiStartCallStatus | number | string;
24
+ message?: string;
25
+ _id?: string;
26
+ }>;
27
+
10
28
  export function startCallWithUuid(data: any): Promise<boolean>;
11
29
  export function joinCall(): Promise<any>;
12
30
  export function endCall(): Promise<any>;
@@ -25,30 +43,112 @@ declare module 'omikit-plugin' {
25
43
  export function systemAlertWindow(): Promise<boolean>;
26
44
  export function openSystemAlertSetting(): Promise<void>;
27
45
  export function getAudio(): Promise<any>;
28
- export function setAudio(data: any): Promise<void>;
46
+ export function setAudio(data: { portType: OmiAudioType | number }): Promise<void>;
29
47
  export function getCurrentAudio(): Promise<any>;
30
48
  export function transferCall(data: any): Promise<boolean>;
31
49
  export function rejectCall(): Promise<boolean>;
32
50
  export function dropCall(): Promise<boolean>;
33
- export function testEventEmission(): Promise<boolean>;
34
51
  export function getKeepAliveStatus(): Promise<any>;
35
52
  export function triggerKeepAlivePing(): Promise<boolean>;
36
53
  export function checkPermissionStatus(): Promise<any>;
37
54
  export function checkAndRequestPermissions(isVideo?: boolean): Promise<boolean>;
38
55
  export function requestSystemAlertWindowPermission(): Promise<boolean>;
39
56
  export function requestPermissionsByCodes(codes: number[]): Promise<boolean>;
57
+ export function hideSystemNotificationSafely(): Promise<boolean>;
58
+ export function hideSystemNotificationOnly(): Promise<boolean>;
59
+ export function hideSystemNotificationAndUnregister(reason: string): Promise<boolean>;
60
+ export function checkCredentials(data: any): Promise<{
61
+ success: boolean;
62
+ statusCode?: number;
63
+ message?: string;
64
+ }>;
65
+ export function registerWithOptions(data: any): Promise<{
66
+ success: boolean;
67
+ statusCode?: number;
68
+ message?: string;
69
+ }>;
70
+
71
+ // User & Info
72
+ export function getUserInfo(phone: string): Promise<any>;
40
73
 
74
+ // Getter Functions
75
+ /** Get the current project ID */
76
+ export function getProjectId(): Promise<string | null>;
77
+ /** Get the current app ID */
78
+ export function getAppId(): Promise<string | null>;
79
+ /** Get the current device ID */
80
+ export function getDeviceId(): Promise<string | null>;
81
+ /** Get the FCM token (Android) or push token */
82
+ export function getFcmToken(): Promise<string | null>;
83
+ /** Get SIP registration info (format: user@realm) */
84
+ export function getSipInfo(): Promise<string | null>;
85
+ /** Get VoIP token (iOS only, returns null on Android) */
86
+ export function getVoipToken(): Promise<string | null>;
87
+
88
+ // ============================================
89
+ // ENUMS
90
+ // ============================================
91
+
92
+ /**
93
+ * Call state enum for tracking call lifecycle
94
+ */
41
95
  export enum OmiCallState {
42
- unknown,
43
- calling,
44
- incoming,
45
- early,
46
- connecting,
47
- confirmed,
48
- disconnected,
49
- hold,
96
+ unknown = 0,
97
+ calling = 1,
98
+ incoming = 2,
99
+ early = 3,
100
+ connecting = 4,
101
+ confirmed = 5,
102
+ disconnected = 6,
103
+ hold = 7,
50
104
  }
51
105
 
106
+ /**
107
+ * Status codes returned by startCall() function
108
+ * Use these to handle different call initiation results
109
+ */
110
+ export enum OmiStartCallStatus {
111
+ // Validation errors (0-3)
112
+ invalidUuid = 0,
113
+ invalidPhoneNumber = 1,
114
+ samePhoneNumber = 2,
115
+ maxRetry = 3,
116
+
117
+ // Permission errors (4, 450-452)
118
+ permissionDenied = 4,
119
+ permissionMicrophone = 450,
120
+ permissionCamera = 451,
121
+ permissionOverlay = 452,
122
+
123
+ // Call errors (5-7)
124
+ couldNotFindEndpoint = 5,
125
+ accountRegisterFailed = 6,
126
+ startCallFailed = 7,
127
+
128
+ // Success statuses (8, 407)
129
+ startCallSuccess = 8,
130
+ startCallSuccessIOS = 407,
131
+
132
+ // Other errors (9+)
133
+ haveAnotherCall = 9,
134
+ accountTurnOffNumberInternal = 10,
135
+ noNetwork = 11,
136
+ }
137
+
138
+ /**
139
+ * Audio output types for setAudio()
140
+ */
141
+ export enum OmiAudioType {
142
+ receiver = 0,
143
+ speaker = 1,
144
+ bluetooth = 2,
145
+ headphones = 3,
146
+ }
147
+
148
+ // ============================================
149
+ // CONSTANTS & EVENTS
150
+ // ============================================
151
+
52
152
  export const OmiCallEvent: {
53
153
  onCallStateChanged: string;
54
154
  onSpeaker: string;