rns-nativecall 1.3.5 → 1.3.7
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/ios/CallModule.m +31 -3
- package/package.json +1 -1
- package/withNativeCallVoip.js +21 -11
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;
|
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -201,23 +201,32 @@ function withAndroidConfig(config) {
|
|
|
201
201
|
function withIosAppDelegateMod(config) {
|
|
202
202
|
return withAppDelegate(config, (config) => {
|
|
203
203
|
let contents = config.modResults.contents;
|
|
204
|
+
|
|
205
|
+
// 1. Ensure RCTLinkingManager is imported if it's a Swift file
|
|
206
|
+
// Note: Expo 51+ uses Swift by default for AppDelegate
|
|
204
207
|
if (!contents.includes('import React')) {
|
|
205
208
|
contents = 'import React\n' + contents;
|
|
206
209
|
}
|
|
207
210
|
|
|
211
|
+
// 2. Add the URL Scheme handler (Required for openURL to work)
|
|
212
|
+
if (!contents.includes('open url: URL')) {
|
|
213
|
+
const openUrlCode = `
|
|
214
|
+
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
|
215
|
+
return RCTLinkingManager.application(app, open: url, options: options)
|
|
216
|
+
}`;
|
|
217
|
+
// Insert before the last closing brace
|
|
218
|
+
contents = contents.replace(/\n}\s*$/, `\n${openUrlCode}\n}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 3. Keep your existing User Activity handler
|
|
208
222
|
if (!contents.includes('continue userActivity')) {
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
) -> Bool {
|
|
215
|
-
let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
|
|
216
|
-
return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
|
|
217
|
-
}
|
|
218
|
-
`;
|
|
219
|
-
contents = contents.replace(/\n}\s*$/, `\n${swiftLinkingCode}\n}`);
|
|
223
|
+
const userActivityCode = `
|
|
224
|
+
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
|
|
225
|
+
return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
|
|
226
|
+
}`;
|
|
227
|
+
contents = contents.replace(/\n}\s*$/, `\n${userActivityCode}\n}`);
|
|
220
228
|
}
|
|
229
|
+
|
|
221
230
|
config.modResults.contents = contents;
|
|
222
231
|
return config;
|
|
223
232
|
});
|
|
@@ -236,6 +245,7 @@ function withIosConfig(config, props = {}) {
|
|
|
236
245
|
});
|
|
237
246
|
}
|
|
238
247
|
|
|
248
|
+
|
|
239
249
|
module.exports = (config, props) => {
|
|
240
250
|
return withPlugins(config, [
|
|
241
251
|
withAndroidConfig,
|