rns-nativecall 1.3.1 โ†’ 1.3.2

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
@@ -1,11 +1,17 @@
1
1
  # rns-nativecall
2
2
 
3
- A professional VoIP incoming call handler for React Native. Features a "Single Call Gate" on Android to manage busy states and full CallKit integration for iOS.
3
+ A **professional VoIP incoming call handler for React Native** with full **Android & iOS native UI integration**.
4
+ Designed for production-grade apps requiring **CallKit**, **lockscreen handling**, **headless execution**, and **single-call enforcement**.
5
+
6
+ ---
4
7
 
5
8
  ## ๐Ÿš€ Highlights
6
- - **Expo Support**: Built-in config plugin handles all native setup.
7
- - **Single Call Gate**: Automatically detects if the user is in a call and flags secondary calls as "BUSY".
8
- - **Headless Mode**: Works even when the app is killed or the screen is locked.
9
+
10
+ - ๐Ÿ“ฆ **Expo Ready** โ€“ Zero manual native setup via config plugin
11
+ - โ˜Ž๏ธ **Single Call Gate** โ€“ Automatically blocks concurrent calls and emits `BUSY` events
12
+ - ๐Ÿง  **Headless Mode** โ€“ Works when the app is killed, backgrounded, or screen locked
13
+ - ๐Ÿ“ฑ **Native UI** โ€“ Full-screen Android Activity & iOS CallKit
14
+ - ๐Ÿ”” **System-Level Reliability** โ€“ No JS race conditions, no ghost calls
9
15
 
10
16
  ---
11
17
 
@@ -13,15 +19,20 @@ A professional VoIP incoming call handler for React Native. Features a "Single C
13
19
 
14
20
  ```bash
15
21
  npx expo install rns-nativecall expo-build-properties react-native-uuid
16
-
17
22
  ```
23
+
18
24
  or
25
+
19
26
  ```bash
20
27
  npm install rns-nativecall expo-build-properties react-native-uuid
21
-
22
28
  ```
23
- ---
24
- Add the plugin to your app.json or app.config.js:
29
+
30
+ ---
31
+
32
+ ## โš™๏ธ Expo Configuration
33
+
34
+ Add the plugin to **app.json** or **app.config.js**:
35
+
25
36
  ```json
26
37
  {
27
38
  "expo": {
@@ -54,11 +65,15 @@ Add the plugin to your app.json or app.config.js:
54
65
  }
55
66
  }
56
67
  ```
68
+
57
69
  ---
58
- ### ๐Ÿ›  Usage
59
70
 
60
- 1. Initialize Headless Task (index.js)
61
- Register the task at the very top of your entry file. This handles background calls and "Busy" signals for secondary callers.
71
+ ## ๐Ÿ›  Usage
72
+
73
+ ### 1๏ธโƒฃ Register Headless Task (index.js)
74
+
75
+ This enables background handling, busy-state signaling, and cold-start execution.
76
+
62
77
  ```javascript
63
78
  import { AppRegistry } from 'react-native';
64
79
  import App from './App';
@@ -66,51 +81,41 @@ import { CallHandler } from 'rns-nativecall';
66
81
 
67
82
  CallHandler.registerHeadlessTask(async (data, eventType) => {
68
83
  if (eventType === 'BUSY') {
69
- // User is already on a call. Notify the second caller via WebSocket/API.
70
- console.log("System Busy for UUID:", data.callUuid);
84
+ console.log("User already in call:", data.callUuid);
71
85
  return;
72
86
  }
73
87
 
74
88
  if (eventType === 'INCOMING_CALL') {
75
- // App is waking up for a new call.
76
- // Trigger your custom UI or logic here.
89
+ console.log("Incoming call payload:", data);
77
90
  }
78
91
  });
79
92
 
80
93
  AppRegistry.registerComponent('main', () => App);
81
94
  ```
82
- ## Handling Events (Index.js)
95
+
96
+ ---
97
+
98
+ ## ๐ŸŽง Foreground Event Handling (index.js)
83
99
 
84
100
  ```javascript
85
- // Index.js Setup Foreground Listeners
86
101
  CallHandler.subscribe(
87
-
88
102
  async (data) => {
89
- try {
90
- console.log("APP IS OPEN", data)
91
- // navigate here
92
- } catch (error) {
93
- console.log("pending_call_uuid", error)
94
- }
103
+ console.log("CALL ACCEPTED", data);
95
104
  },
96
-
97
105
  async (data) => {
98
- try {
99
- console.log("CALL DECLINE", data)
100
- // update the caller here call decline
101
- } catch (error) {
102
- console.log("Onreject/ cancel call error", error)
103
- }
106
+ console.log("CALL REJECTED", data);
104
107
  },
105
-
106
- (data) => { console.log("failded", data) }
108
+ (data) => {
109
+ console.log("CALL FAILED", data);
110
+ }
107
111
  );
108
-
109
112
  ```
110
- ## Handling Events (App.js)
111
113
 
112
- ```javascript
114
+ ---
113
115
 
116
+ ## ๐ŸŽฌ App-Level Integration (App.js)
117
+
118
+ ```javascript
114
119
  import React, { useEffect } from 'react';
115
120
  import { CallHandler } from 'rns-nativecall';
116
121
 
@@ -119,18 +124,15 @@ export default function App() {
119
124
  const unsubscribe = CallHandler.subscribe(
120
125
  (data) => {
121
126
  console.log("Call Accepted:", data.callUuid);
122
- // Navigate to your call screen
123
127
  },
124
128
  (data) => {
125
129
  console.log("Call Rejected:", data.callUuid);
126
- // Send 'Hangup' signal to your server
127
130
  }
128
131
  );
129
132
 
130
133
  return () => unsubscribe();
131
134
  }, []);
132
135
 
133
- // To manually trigger the UI (e.g., from an FCM data message)
134
136
  const showCall = () => {
135
137
  CallHandler.displayCall("unique-uuid", "Caller Name", "video");
136
138
  };
@@ -138,51 +140,62 @@ export default function App() {
138
140
  return <YourUI />;
139
141
  }
140
142
  ```
143
+
141
144
  ---
142
- ## ๐Ÿ“– rns-nativecall API Reference
143
145
 
146
+ ## ๐Ÿ“– API Reference
144
147
 
145
148
  ### Core Methods
149
+
146
150
  | Method | Platform | Description |
147
- | :--- | :--- | :--- |
148
- | **registerHeadlessTask(callback)** | All | Registers the background task. `eventType` is 'INCOMING_CALL', 'BUSY', or 'ABORTED_CALL'. |
149
- | **displayCall(uuid, name, type)** | All | Launches full-screen Activity (Android) or reports to CallKit (iOS). |
150
- | **destroyNativeCallUI(uuid)** | All | Stops ringtone/Activity (Android) or ends CallKit session (iOS). |
151
- | **subscribe(onAccept, onReject, onFailed)** | All | Listens for Answer/Decline actions and system-level bridge errors. |
152
- | **showMissedCall(uuid, name, type)** | Android | Posts a persistent notification in the device tray for missed calls. |
153
- | **showOnGoingCall(uuid, name, type)** | Android | Show a persistent notification in the device tray for on going calls. |
154
-
155
- ### Data & State Management
151
+ |------|---------|-------------|
152
+ | `registerHeadlessTask(cb)` | All | Registers background task (`INCOMING_CALL`, `BUSY`, `ABORTED_CALL`) |
153
+ | `displayCall(uuid, name, type)` | All | Shows native incoming call UI |
154
+ | `destroyNativeCallUI(uuid)` | All | Ends native UI / CallKit session |
155
+ | `subscribe(onAccept, onReject, onFail)` | All | Listen to call actions |
156
+ | `showMissedCall(uuid, name, type)` | Android | Persistent missed call notification |
157
+ | `showOnGoingCall(uuid, name, type)` | Android | Persistent ongoing call notification |
158
+
159
+ ---
160
+
161
+ ### Data & State
162
+
156
163
  | Method | Platform | Description |
157
- | :--- | :--- | :--- |
158
- | **getInitialCallData()** | All | Retrieves the call payload if the app was cold-started via a notification. |
159
- | **checkCallValidity(uuid)** | All | Returns `{isValid, isCanceled}` to prevent ghost or aborted calls. |
160
- | **checkCallStatus(uuid)** | All | Returns `{isCanceled, isActive, shouldDisplay}` for UI syncing. |
164
+ |------|---------|-------------|
165
+ | `getInitialCallData()` | All | Retrieve payload from cold start |
166
+ | `checkCallValidity(uuid)` | All | Prevent ghost calls |
167
+ | `checkCallStatus(uuid)` | All | Sync UI with native state |
168
+
169
+ ---
161
170
 
162
171
  ### Android Permissions
163
- | Method | Platform | Description |
164
- | :--- | :--- | :--- |
165
- | **checkOverlayPermission()** | Android | Returns `true` if app can draw over other apps (Heads-up UI). |
166
- | **checkFullScreenPermission()** | Android | (Android 14+) Checks if app can trigger full-screen intents. |
167
- | **requestOverlayPermission()** | Android | Navigates user to "Draw over other apps" system settings. |
168
- | **requestFullScreenSettings()** | Android | (Android 14+) Navigates user to "Full Screen Intent" settings. |
172
+
173
+ | Method | Description |
174
+ |------|-------------|
175
+ | `checkOverlayPermission()` | Check lockscreen overlay permission |
176
+ | `requestOverlayPermission()` | Open overlay settings |
177
+ | `checkFullScreenPermission()` | Android 14+ full screen intent |
178
+ | `requestFullScreenSettings()` | Android 14+ permission screen |
169
179
 
170
180
  ---
171
181
 
172
- # Implementation Notes
182
+ ## ๐Ÿง  Implementation Notes
173
183
 
174
- 1. Android Overlay:
175
- For your React Native call screen to show up when the phone is locked, the user must grant the "Overlay Permission". Use 'checkOverlayPermission()' and 'requestOverlayPermission()' during your app's onboarding or call initiation.
184
+ ### Android Overlay
185
+ Overlay permission is required to display calls on the lockscreen.
186
+ Request during onboarding or before first call.
176
187
 
177
- 2. iOS CallKit:
178
- On iOS, 'displayCall' uses the native system CallKit UI. This works automatically in the background and on the lockscreen without extra overlay permissions.
188
+ ### iOS CallKit
189
+ Uses system CallKit UI. Works automatically in background and lockscreen.
190
+
191
+ ### Single Call Gate
192
+ If a call is active, all subsequent calls emit `BUSY` via headless task.
179
193
 
180
- 3. Single Call Gate:
181
- The library automatically prevents multiple overlapping native UIs. If a call is already active, subsequent calls will trigger the 'BUSY' event in your Headless Task.
182
194
  ---
183
195
 
184
- ## FULL Example Use Case
185
- ```javascript
196
+ ## ๐Ÿงช Full Example
197
+
198
+ ```js
186
199
  import React, { useEffect, useState } from 'react';
187
200
  import { StyleSheet, Text, View, TouchableOpacity, Alert } from 'react-native';
188
201
  import { CallHandler } from 'rns-nativecall';
@@ -275,5 +288,13 @@ const styles = StyleSheet.create({
275
288
  btnText: { color: 'white', fontWeight: 'bold' }
276
289
  });
277
290
  ```
291
+
292
+ ---
293
+
278
294
  ## ๐Ÿ›ก License
295
+
296
+ MIT License
297
+
279
298
  ---
299
+
300
+ Built for **production VoIP apps**, not demos.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "High-performance React Native module for handling native VoIP call UI on Android and iOS.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,8 @@
20
20
  "url": "git+https://github.com/raiidr/rns-nativecall.git"
21
21
  },
22
22
  "scripts": {
23
- "p": "npm publish --access public"
23
+ "p": "npm publish --access public",
24
+ "i": "npm publish --access public"
24
25
  },
25
26
  "keywords": [
26
27
  "react-native",
@@ -107,6 +107,7 @@ function withAndroidConfig(config) {
107
107
  'android.permission.POST_NOTIFICATIONS',
108
108
  'android.permission.WAKE_LOCK',
109
109
  'android.permission.DISABLE_KEYGUARD',
110
+ 'android.permission.MANAGE_OWN_CALLS',
110
111
  ];
111
112
 
112
113
  manifest.manifest['uses-permission'] = manifest.manifest['uses-permission'] || [];