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 +89 -68
- package/package.json +3 -2
- package/withNativeCallVoip.js +1 -0
package/README.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# rns-nativecall
|
|
2
2
|
|
|
3
|
-
A professional VoIP incoming call handler for React Native
|
|
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
|
-
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
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
|
-
|
|
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
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
+
(data) => {
|
|
109
|
+
console.log("CALL FAILED", data);
|
|
110
|
+
}
|
|
107
111
|
);
|
|
108
|
-
|
|
109
112
|
```
|
|
110
|
-
## Handling Events (App.js)
|
|
111
113
|
|
|
112
|
-
|
|
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
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
|
159
|
-
|
|
|
160
|
-
|
|
|
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
|
-
|
|
164
|
-
|
|
|
165
|
-
|
|
166
|
-
|
|
|
167
|
-
|
|
|
168
|
-
|
|
|
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
|
-
|
|
182
|
+
## ๐ง Implementation Notes
|
|
173
183
|
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
178
|
-
|
|
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
|
-
##
|
|
185
|
-
|
|
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.
|
|
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",
|
package/withNativeCallVoip.js
CHANGED
|
@@ -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'] || [];
|