rns-nativecall 0.9.2 → 0.9.4

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.2",
3
+ "version": "0.9.4",
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",
@@ -83,13 +83,12 @@ function withAndroidConfig(config) {
83
83
  mainActivity.$['android:turnScreenOn'] = 'true';
84
84
  }
85
85
 
86
- //'android.permission.FOREGROUND_SERVICE_PHONE_CALL',
87
- //'android.permission.MANAGE_ONGOING_CALLS'
88
- //'android.permission.USE_FULL_SCREEN_INTENT',
89
-
90
86
  const permissions = [
91
87
  'android.permission.VIBRATE',
92
88
  'android.permission.FOREGROUND_SERVICE',
89
+ 'android.permission.FOREGROUND_SERVICE_PHONE_CALL', // ADDED THIS
90
+ 'android.permission.USE_FULL_SCREEN_INTENT', // ADDED THIS
91
+ 'android.permission.MANAGE_ONGOING_CALLS', // ADDED THIS
93
92
  'android.permission.POST_NOTIFICATIONS',
94
93
  'android.permission.WAKE_LOCK',
95
94
  'android.permission.DISABLE_KEYGUARD',
@@ -157,24 +156,16 @@ function withIosAppDelegateMod(config) {
157
156
  return withAppDelegate(config, (config) => {
158
157
  let contents = config.modResults.contents;
159
158
 
160
- // 1. In Swift, we don't use #import. We just ensure 'React' is imported.
159
+ // 1. Surgical Import: Add 'import React' at the very top if missing
161
160
  if (!contents.includes('import React')) {
162
- contents = contents.replace(/import ExpoAppDelegate/, 'import React\nimport ExpoAppDelegate');
161
+ contents = 'import React\n' + contents;
163
162
  }
164
163
 
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
- );
174
- }
175
- } else {
176
- // 3. If the method doesn't exist at all, add the Swift version before the last closing brace
164
+ // 2. Check for the continue userActivity method
165
+ if (!contents.includes('continue userActivity')) {
166
+ // Method is missing, inject it before the final closing brace of the class
177
167
  const swiftLinkingCode = `
168
+ // Universal Links
178
169
  public override func application(
179
170
  _ application: UIApplication,
180
171
  continue userActivity: NSUserActivity,
@@ -184,7 +175,14 @@ function withIosAppDelegateMod(config) {
184
175
  return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
185
176
  }
186
177
  `;
187
- contents = contents.replace(/}\s*$/, `${swiftLinkingCode}\n}`);
178
+ // This regex finds the last '}' in the file (closing the AppDelegate class)
179
+ contents = contents.replace(/\n}\s*$/, `\n${swiftLinkingCode}\n}`);
180
+ } else if (!contents.includes('RCTLinkingManager.application')) {
181
+ // Method exists but is missing our logic, inject it inside
182
+ contents = contents.replace(
183
+ /continue userActivity: NSUserActivity,[\s\S]*?\) -> Bool \{/,
184
+ `continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {\n let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)`
185
+ );
188
186
  }
189
187
 
190
188
  config.modResults.contents = contents;