rns-nativecall 0.9.2 → 0.9.3
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 +14 -15
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -157,24 +157,16 @@ function withIosAppDelegateMod(config) {
|
|
|
157
157
|
return withAppDelegate(config, (config) => {
|
|
158
158
|
let contents = config.modResults.contents;
|
|
159
159
|
|
|
160
|
-
// 1.
|
|
160
|
+
// 1. Surgical Import: Add 'import React' at the very top if missing
|
|
161
161
|
if (!contents.includes('import React')) {
|
|
162
|
-
contents =
|
|
162
|
+
contents = 'import React\n' + contents;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
// 2.
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
);
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
// 3. If the method doesn't exist at all, add the Swift version before the last closing brace
|
|
165
|
+
// 2. Check for the continue userActivity method
|
|
166
|
+
if (!contents.includes('continue userActivity')) {
|
|
167
|
+
// Method is missing, inject it before the final closing brace of the class
|
|
177
168
|
const swiftLinkingCode = `
|
|
169
|
+
// Universal Links
|
|
178
170
|
public override func application(
|
|
179
171
|
_ application: UIApplication,
|
|
180
172
|
continue userActivity: NSUserActivity,
|
|
@@ -184,7 +176,14 @@ function withIosAppDelegateMod(config) {
|
|
|
184
176
|
return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
|
|
185
177
|
}
|
|
186
178
|
`;
|
|
187
|
-
|
|
179
|
+
// This regex finds the last '}' in the file (closing the AppDelegate class)
|
|
180
|
+
contents = contents.replace(/\n}\s*$/, `\n${swiftLinkingCode}\n}`);
|
|
181
|
+
} else if (!contents.includes('RCTLinkingManager.application')) {
|
|
182
|
+
// Method exists but is missing our logic, inject it inside
|
|
183
|
+
contents = contents.replace(
|
|
184
|
+
/continue userActivity: NSUserActivity,[\s\S]*?\) -> Bool \{/,
|
|
185
|
+
`continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {\n let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)`
|
|
186
|
+
);
|
|
188
187
|
}
|
|
189
188
|
|
|
190
189
|
config.modResults.contents = contents;
|