rns-nativecall 0.9.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "High-performance React Native module for handling native VoIP call UI on Android and iOS.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -157,34 +157,33 @@ function withIosAppDelegateMod(config) {
157
157
  return withAppDelegate(config, (config) => {
158
158
  let contents = config.modResults.contents;
159
159
 
160
- // 1. Check for the import
161
- if (!contents.includes('#import <React/RCTLinkingManager.h>')) {
162
- contents = '#import <React/RCTLinkingManager.h>\n' + contents;
160
+ // 1. Surgical Import: Add 'import React' at the very top if missing
161
+ if (!contents.includes('import React')) {
162
+ contents = 'import React\n' + contents;
163
163
  }
164
164
 
165
- // 2. Only inject if the method name doesn't exist AT ALL
166
- // This prevents the "Duplicate Method" error
167
- if (!contents.includes('continueUserActivity')) {
168
- const linkingCode = `
169
- - (BOOL)application:(UIApplication *)application
170
- continueUserActivity:(NSUserActivity *)userActivity
171
- restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
172
- {
173
- return [RCTLinkingManager application:application
174
- continueUserActivity:userActivity
175
- restorationHandler:restorationHandler];
176
- }
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
168
+ const swiftLinkingCode = `
169
+ // Universal Links
170
+ public override func application(
171
+ _ application: UIApplication,
172
+ continue userActivity: NSUserActivity,
173
+ restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
174
+ ) -> Bool {
175
+ let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
176
+ return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
177
+ }
177
178
  `;
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.");
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;