rns-nativecall 1.1.2 → 1.1.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.
@@ -118,6 +118,14 @@ object NativeCallManager {
118
118
  }
119
119
  }
120
120
 
121
+ fun refreshNotificationOnly(
122
+ context: Context,
123
+ uuid: String,
124
+ ) {
125
+ val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
126
+ manager.cancel(uuid.hashCode())
127
+ }
128
+
121
129
  fun dismissIncomingCall(
122
130
  context: Context,
123
131
  uuid: String?,
@@ -11,14 +11,10 @@ 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
-
18
15
  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.
16
+ val uuid = activeData["callUuid"] ?: "" // Use map access [] instead of getString
17
+ NativeCallManager.refreshNotificationOnly(context, uuid)
22
18
  NativeCallManager.handleIncomingPush(context, activeData)
23
19
  }
24
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "1.1.2",
3
+ "version": "1.1.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",
@@ -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
  }