rns-nativecall 1.1.4 → 1.1.5

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": "1.1.4",
3
+ "version": "1.1.5",
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",
@@ -40,7 +40,6 @@ function withMainActivityDataFix(config) {
40
40
  `;
41
41
 
42
42
  if (contents.includes('override fun onCreate')) {
43
- // If onCreate exists, inject logic after super.onCreate
44
43
  if (!contents.includes('setShowWhenLocked(true)')) {
45
44
  contents = contents.replace(
46
45
  /super\.onCreate\(.*\)/,
@@ -49,23 +48,27 @@ function withMainActivityDataFix(config) {
49
48
  }
50
49
  }
51
50
 
52
- // 3. Inject VoIP logic into EXISTING onNewIntent
53
- const voipOnNewIntentLogic = `
54
- setIntent(intent)`;
55
-
56
- if (contents.includes('override fun onNewIntent')) {
57
- if (!contents.includes('setIntent(intent)')) {
58
- contents = contents.replace(
59
- /super\.onNewIntent\(intent\)/,
60
- (match) => `${match}\n${voipOnNewIntentLogic}`
61
- );
62
- }
51
+ // 3. Handle onNewIntent (Inject method if missing, or fix if exists)
52
+ if (!contents.includes('override fun onNewIntent')) {
53
+ const onNewIntentCode = `
54
+ override fun onNewIntent(intent: Intent) {
55
+ super.onNewIntent(intent)
56
+ setIntent(intent)
57
+ }
58
+ `;
59
+ contents = contents.replace(/class MainActivity\s*:\s*ReactActivity\(\)\s*\{/, (match) => `${match}${onNewIntentCode}`);
60
+ } else if (!contents.includes('setIntent(intent)')) {
61
+ contents = contents.replace(
62
+ /super\.onNewIntent\(intent\)/,
63
+ (match) => `super.onNewIntent(intent)\n setIntent(intent)`
64
+ );
63
65
  }
64
66
 
65
67
  config.modResults.contents = contents;
66
68
  return config;
67
69
  });
68
70
  }
71
+
69
72
  /** 2. ANDROID MANIFEST CONFIG **/
70
73
  function withAndroidConfig(config) {
71
74
  return withAndroidManifest(config, (config) => {
@@ -166,19 +169,17 @@ function withAndroidConfig(config) {
166
169
  return config;
167
170
  });
168
171
  }
169
- /** 2. IOS APP DELEGATE MOD (The fix for Lock Screen Answer) **/
172
+
173
+ /** 2. IOS APP DELEGATE MOD **/
170
174
  function withIosAppDelegateMod(config) {
171
175
  return withAppDelegate(config, (config) => {
172
176
  let contents = config.modResults.contents;
173
177
 
174
- // 1. Surgical Import: Add 'import React' at the very top if missing
175
178
  if (!contents.includes('import React')) {
176
179
  contents = 'import React\n' + contents;
177
180
  }
178
181
 
179
- // 2. Check for the continue userActivity method
180
182
  if (!contents.includes('continue userActivity')) {
181
- // Method is missing, inject it before the final closing brace of the class
182
183
  const swiftLinkingCode = `
183
184
  // Universal Links
184
185
  public override func application(
@@ -190,10 +191,8 @@ function withIosAppDelegateMod(config) {
190
191
  return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
191
192
  }
192
193
  `;
193
- // This regex finds the last '}' in the file (closing the AppDelegate class)
194
194
  contents = contents.replace(/\n}\s*$/, `\n${swiftLinkingCode}\n}`);
195
195
  } else if (!contents.includes('RCTLinkingManager.application')) {
196
- // Method exists but is missing our logic, inject it inside
197
196
  contents = contents.replace(
198
197
  /continue userActivity: NSUserActivity,[\s\S]*?\) -> Bool \{/,
199
198
  `continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {\n let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)`
@@ -204,7 +203,8 @@ function withIosAppDelegateMod(config) {
204
203
  return config;
205
204
  });
206
205
  }
207
- /** 3. IOS INFO.PLIST CONFIG (Existing) **/
206
+
207
+ /** 3. IOS INFO.PLIST CONFIG **/
208
208
  function withIosConfig(config, props = {}) {
209
209
  return withInfoPlist(config, (config) => {
210
210
  const infoPlist = config.modResults;
@@ -219,12 +219,13 @@ function withIosConfig(config, props = {}) {
219
219
  return config;
220
220
  });
221
221
  }
222
+
222
223
  // Main Plugin Entry
223
224
  module.exports = (config, props) => {
224
225
  return withPlugins(config, [
225
226
  withAndroidConfig,
226
227
  withMainActivityDataFix,
227
- withIosAppDelegateMod, // <--- ADDED THIS HERE
228
+ withIosAppDelegateMod,
228
229
  [withIosConfig, props]
229
230
  ]);
230
231
  };