rns-nativecall 1.1.2 → 1.1.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.
@@ -11,15 +11,16 @@ class UnlockReceiver : BroadcastReceiver() {
11
11
  intent: Intent,
12
12
  ) {
13
13
  if (intent.action == Intent.ACTION_USER_PRESENT) {
14
- Log.d("UnlockReceiver", "Device Unlocked - Re-triggering Notification Pill")
15
-
16
14
  val activeData = NativeCallManager.getCurrentCallData()
17
15
 
18
16
  if (activeData != null) {
19
- // We don't launch the app!
20
- // We just tell the Manager to show the notification again.
21
- // This forces the "Heads-Up" (Pill) to appear on the home screen.
17
+ // IMPORTANT: Ensure the notification channel used here
18
+ // has "Importance: High" to force the Heads-Up display.
22
19
  NativeCallManager.handleIncomingPush(context, activeData)
20
+
21
+ // Optional: If you want to force the React Native app to open
22
+ // immediately upon unlock without the user touching the banner:
23
+ // NativeCallManager.launchApp(context)
23
24
  }
24
25
  }
25
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "1.1.2",
3
+ "version": "1.1.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",
@@ -1,5 +1,6 @@
1
1
  const { withAndroidManifest, withInfoPlist, withPlugins, withMainActivity, withAppDelegate } = require('@expo/config-plugins');
2
2
 
3
+ /** 1. MAIN ACTIVITY MOD **/
3
4
  function withMainActivityDataFix(config) {
4
5
  return withMainActivity(config, (config) => {
5
6
  let contents = config.modResults.contents;
@@ -13,56 +14,52 @@ function withMainActivityDataFix(config) {
13
14
  'import android.Manifest'
14
15
  ];
15
16
 
16
- // Add imports if they don't exist
17
+ // 1. Add missing imports
17
18
  imports.forEach(imp => {
18
19
  if (!contents.includes(imp)) {
19
20
  contents = contents.replace(/package .*/, (match) => `${match}\n${imp}`);
20
21
  }
21
22
  });
22
23
 
23
- const onCreateCode = `
24
- override fun onCreate(savedInstanceState: Bundle?) {
25
- super.onCreate(savedInstanceState)
26
-
27
- // Request Notification Permissions for Android 13+ (Required for Pill UI)
24
+ // 2. Inject VoIP logic into EXISTING onCreate
25
+ const voipOnCreateLogic = `
28
26
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
29
- ActivityCompat.requestPermissions(
30
- this,
31
- arrayOf(Manifest.permission.POST_NOTIFICATIONS),
32
- 101
33
- )
27
+ ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 101)
34
28
  }
35
29
 
36
30
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
37
31
  setShowWhenLocked(true)
38
32
  setTurnScreenOn(true)
39
33
  } else {
40
- window.addFlags(
41
- WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
42
- WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
43
- WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
44
- )
34
+ window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
45
35
  }
46
36
 
47
37
  if (intent.getBooleanExtra("background_wake", false)) {
48
38
  moveTaskToBack(true)
49
39
  }
50
- }`;
51
-
52
- const onNewIntentCode = `
53
- override fun onNewIntent(intent: Intent) {
54
- super.onNewIntent(intent)
55
- setIntent(intent)
56
- }`;
57
-
58
- const classRegex = /class MainActivity\s*:\s*ReactActivity\(\)\s*\{/;
59
-
60
- if (!contents.includes('override fun onCreate')) {
61
- contents = contents.replace(classRegex, (match) => `${match}${onCreateCode}`);
40
+ `;
41
+
42
+ if (contents.includes('override fun onCreate')) {
43
+ // If onCreate exists, inject logic after super.onCreate
44
+ if (!contents.includes('setShowWhenLocked(true)')) {
45
+ contents = contents.replace(
46
+ /super\.onCreate\(.*\)/,
47
+ (match) => `${match}\n${voipOnCreateLogic}`
48
+ );
49
+ }
62
50
  }
63
51
 
64
- if (!contents.includes('override fun onNewIntent')) {
65
- contents = contents.replace(classRegex, (match) => `${match}${onNewIntentCode}`);
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
+ }
66
63
  }
67
64
 
68
65
  config.modResults.contents = contents;
@@ -149,6 +146,23 @@ function withAndroidConfig(config) {
149
146
  application.receiver.push({ $: { 'android:name': 'com.rnsnativecall.CallActionReceiver', 'android:exported': 'false' } });
150
147
  }
151
148
 
149
+ // 2. ADDED UnlockReceiver with intent-filter
150
+ if (!application.receiver.some(r => r.$['android:name'] === 'com.rnsnativecall.UnlockReceiver')) {
151
+ application.receiver.push({
152
+ $: {
153
+ 'android:name': 'com.rnsnativecall.UnlockReceiver',
154
+ 'android:exported': 'false'
155
+ },
156
+ 'intent-filter': [
157
+ {
158
+ action: [
159
+ { $: { 'android:name': 'android.intent.action.USER_PRESENT' } }
160
+ ]
161
+ }
162
+ ]
163
+ });
164
+ }
165
+
152
166
  return config;
153
167
  });
154
168
  }