rns-nativecall 1.3.3 → 1.3.5
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 +29 -17
- package/index.d.ts +5 -0
- package/index.js +27 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -173,6 +173,7 @@ export default function App() {
|
|
|
173
173
|
| Method | Description |
|
|
174
174
|
|------|-------------|
|
|
175
175
|
| `checkOverlayPermission()` | Check lockscreen overlay permission |
|
|
176
|
+
| `requestNotificationPermission()` | Check notification permission |
|
|
176
177
|
| `requestOverlayPermission()` | Open overlay settings |
|
|
177
178
|
| `checkFullScreenPermission()` | Android 14+ full screen intent |
|
|
178
179
|
| `requestFullScreenSettings()` | Android 14+ permission screen |
|
|
@@ -230,27 +231,38 @@ export default function App() {
|
|
|
230
231
|
}, []);
|
|
231
232
|
|
|
232
233
|
const startTestCall = async () => {
|
|
233
|
-
//
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
234
|
+
// 1. Check/Request Notifications first (Standard Popup)
|
|
235
|
+
const hasNotify = await CallHandler.requestNotificationPermission();
|
|
236
|
+
if (!hasNotify) {
|
|
237
|
+
Alert.alert("Permission Required", "Notifications must be enabled to receive calls.");
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// 2. Check Overlay (Special System Setting)
|
|
242
|
+
const hasOverlay = await CallHandler.checkOverlayPermission();
|
|
243
|
+
|
|
244
|
+
if (!hasOverlay) {
|
|
245
|
+
Alert.alert(
|
|
246
|
+
"Display Over Other Apps",
|
|
247
|
+
"To see calls while using other apps or when locked, please enable the 'Overlay' permission.",
|
|
248
|
+
[
|
|
249
|
+
{ text: "Cancel", style: "cancel" },
|
|
250
|
+
{
|
|
251
|
+
text: "Go to Settings",
|
|
252
|
+
onPress: () => CallHandler.requestOverlayPermission()
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
);
|
|
256
|
+
return; // Stop here; the user is now in Settings
|
|
245
257
|
}
|
|
246
258
|
|
|
247
|
-
//
|
|
259
|
+
// 3. Success! Both permissions are active
|
|
248
260
|
CallHandler.displayCall(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
261
|
+
uuid.v4(),
|
|
262
|
+
"John Doe",
|
|
263
|
+
"video"
|
|
252
264
|
);
|
|
253
|
-
|
|
265
|
+
};
|
|
254
266
|
|
|
255
267
|
const endCallManually = () => {
|
|
256
268
|
if (activeCall) {
|
package/index.d.ts
CHANGED
|
@@ -93,6 +93,11 @@ export interface CallHandlerType {
|
|
|
93
93
|
*/
|
|
94
94
|
checkOverlayPermission(): Promise<boolean>;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Checks if the app has permission to show incoming notification pill.
|
|
98
|
+
*/
|
|
99
|
+
requestNotificationPermission(): Promise<boolean>;
|
|
100
|
+
|
|
96
101
|
/**
|
|
97
102
|
* Checks if the app has permission to use full screen intent.
|
|
98
103
|
*/
|
package/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
NativeEventEmitter,
|
|
4
4
|
AppRegistry,
|
|
5
5
|
Platform,
|
|
6
|
+
PermissionsAndroid, // Import this
|
|
7
|
+
Linking,
|
|
6
8
|
} from 'react-native';
|
|
7
9
|
|
|
8
10
|
const { CallModule } = NativeModules;
|
|
@@ -80,6 +82,31 @@ export const CallHandler = {
|
|
|
80
82
|
|
|
81
83
|
//--------------------------------------------------------------------------------------
|
|
82
84
|
|
|
85
|
+
|
|
86
|
+
requestNotificationPermission: async () => {
|
|
87
|
+
if (Platform.OS === 'android') {
|
|
88
|
+
// Android 13+ (API 33+) requires the RUNTIME prompt
|
|
89
|
+
if (Platform.Version >= 33) {
|
|
90
|
+
const status = await PermissionsAndroid.request('android.permission.POST_NOTIFICATIONS');
|
|
91
|
+
return status === PermissionsAndroid.RESULTS.GRANTED;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Android 12 and below: Permissions are granted at install.
|
|
95
|
+
// If they are missing, it means the user MANUALLY disabled them.
|
|
96
|
+
// You can't "request" them back via code; you must send them to Settings.
|
|
97
|
+
await PermissionsAndroid.check('android.permission.POST_NOTIFICATIONS');
|
|
98
|
+
|
|
99
|
+
return true; // Assume true for old versions, or use Linking if you suspect a block
|
|
100
|
+
}
|
|
101
|
+
return true; // iOS (handled by CallKit)
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
goToSettings: () => {
|
|
105
|
+
if (Platform.OS === 'android') {
|
|
106
|
+
Linking.openSettings();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
|
|
83
110
|
requestOverlayPermission: async () => {
|
|
84
111
|
if (Platform.OS === 'ios') return true;
|
|
85
112
|
if (!CallModule?.requestOverlayPermission) return false;
|