rns-nativecall 0.9.0 → 0.9.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/package.json +1 -1
- package/withNativeCallVoip.js +26 -25
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -157,34 +157,34 @@ function withIosAppDelegateMod(config) {
|
|
|
157
157
|
return withAppDelegate(config, (config) => {
|
|
158
158
|
let contents = config.modResults.contents;
|
|
159
159
|
|
|
160
|
-
// 1.
|
|
161
|
-
if (!contents.includes('
|
|
162
|
-
contents = '
|
|
160
|
+
// 1. In Swift, we don't use #import. We just ensure 'React' is imported.
|
|
161
|
+
if (!contents.includes('import React')) {
|
|
162
|
+
contents = contents.replace(/import ExpoAppDelegate/, 'import React\nimport ExpoAppDelegate');
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
// 2.
|
|
166
|
-
//
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
continueUserActivity:userActivity
|
|
175
|
-
restorationHandler:restorationHandler];
|
|
176
|
-
}
|
|
177
|
-
`;
|
|
178
|
-
// Inject before the LAST @end in the file
|
|
179
|
-
const parts = contents.split('@end');
|
|
180
|
-
const lastPart = parts.pop();
|
|
181
|
-
contents = parts.join('@end') + linkingCode + '\n@end' + lastPart;
|
|
182
|
-
} else {
|
|
183
|
-
// 3. If it DOES exist, ensure RCTLinkingManager is inside it
|
|
184
|
-
// Many Expo apps have an empty continueUserActivity or one that only handles notifications
|
|
185
|
-
if (!contents.includes('RCTLinkingManager')) {
|
|
186
|
-
console.warn("[rns-nativecall] continueUserActivity exists but doesn't have RCTLinkingManager. Manual check required.");
|
|
165
|
+
// 2. Look for the Swift version of continue userActivity
|
|
166
|
+
// We check if it already exists to avoid duplication
|
|
167
|
+
if (contents.includes('continue userActivity')) {
|
|
168
|
+
// If it exists but doesn't have RCTLinkingManager, inject it inside the existing method
|
|
169
|
+
if (!contents.includes('RCTLinkingManager.application')) {
|
|
170
|
+
contents = contents.replace(
|
|
171
|
+
/public override func application\((\s*)_ application: UIApplication,(\s*)continue userActivity: NSUserActivity,/,
|
|
172
|
+
`public override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {\n let _ = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)\n`
|
|
173
|
+
);
|
|
187
174
|
}
|
|
175
|
+
} else {
|
|
176
|
+
// 3. If the method doesn't exist at all, add the Swift version before the last closing brace
|
|
177
|
+
const swiftLinkingCode = `
|
|
178
|
+
public override func application(
|
|
179
|
+
_ application: UIApplication,
|
|
180
|
+
continue userActivity: NSUserActivity,
|
|
181
|
+
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
|
|
182
|
+
) -> Bool {
|
|
183
|
+
let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
|
|
184
|
+
return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
187
|
+
contents = contents.replace(/}\s*$/, `${swiftLinkingCode}\n}`);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
config.modResults.contents = contents;
|
|
@@ -211,6 +211,7 @@ module.exports = (config, props) => {
|
|
|
211
211
|
return withPlugins(config, [
|
|
212
212
|
withAndroidConfig,
|
|
213
213
|
withMainActivityDataFix,
|
|
214
|
+
withIosAppDelegateMod, // <--- ADDED THIS HERE
|
|
214
215
|
[withIosConfig, props]
|
|
215
216
|
]);
|
|
216
217
|
};
|