rns-nativecall 1.3.4 → 1.3.6
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/ios/CallModule.m +31 -3
- 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/ios/CallModule.m
CHANGED
|
@@ -163,19 +163,47 @@ RCT_EXPORT_METHOD(checkCallStatus:(NSString *)uuidString
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
// MARK: - CXProviderDelegate
|
|
166
|
+
- (void)bringAppToForeground {
|
|
167
|
+
if (@available(iOS 13.0, *)) {
|
|
168
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
169
|
+
for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) {
|
|
170
|
+
if (![scene isKindOfClass:[UIWindowScene class]]) continue;
|
|
171
|
+
|
|
172
|
+
if (scene.activationState == UISceneActivationStateForegroundActive) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
[[UIApplication sharedApplication]
|
|
177
|
+
requestSceneSessionActivation:scene.session
|
|
178
|
+
userActivity:nil
|
|
179
|
+
options:nil
|
|
180
|
+
errorHandler:^(NSError *error) {
|
|
181
|
+
NSLog(@"[CallModule] Scene activation failed: %@", error);
|
|
182
|
+
}];
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
166
189
|
|
|
167
190
|
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
|
|
168
191
|
[action fulfill];
|
|
192
|
+
|
|
169
193
|
NSString *uuidStr = [action.callUUID.UUIDString lowercaseString];
|
|
170
194
|
self.pendingCallUuid = uuidStr;
|
|
171
195
|
|
|
196
|
+
// 🔑 Force app UI to foreground FIRST
|
|
197
|
+
[self bringAppToForeground];
|
|
198
|
+
|
|
172
199
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
[self sendEventWithName:@"onCallAccepted" body:@{@"callUuid": uuidStr}];
|
|
200
|
+
[self sendEventWithName:@"onCallAccepted"
|
|
201
|
+
body:@{@"callUuid": uuidStr}];
|
|
176
202
|
});
|
|
177
203
|
}
|
|
178
204
|
|
|
205
|
+
|
|
206
|
+
|
|
179
207
|
- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action {
|
|
180
208
|
[action fulfill];
|
|
181
209
|
self.isCallActive = NO;
|