rns-nativecall 0.4.5 → 0.4.6

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.
@@ -22,7 +22,7 @@ object NativeCallManager {
22
22
  val uuid = data["callUuid"] ?: return
23
23
  val name = data["name"] ?: "Unknown Caller"
24
24
  val handle = data["handle"] ?: ""
25
-
25
+ stopRingtone()
26
26
  val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
27
27
 
28
28
  // 1. Create Channel with High Importance (Required for Heads Up)
@@ -107,8 +107,23 @@ object NativeCallManager {
107
107
 
108
108
  notificationManager.notify(uuid.hashCode(), builder.build())
109
109
  }
110
-
110
+ fun stopRingtone() {
111
+     try {
112
+         // Use the safe call operator ?. to only run if ringtone isn't null
113
+         ringtone?.let {
114
+             if (it.isPlaying) {
115
+                 it.stop()
116
+             }
117
+         }
118
+         // Always null it out after stopping
119
+         ringtone = null
120
+     } catch (e: Exception) {
121
+         // Prevent the app from crashing if the system Ringtone service is acting up
122
+         e.printStackTrace()
123
+         ringtone = null
124
+     }
111
125
  fun dismissIncomingCall(context: Context, uuid: String?) {
126
+ stopRingtone()
112
127
  val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
113
128
  if (uuid != null) notificationManager.cancel(uuid.hashCode())
114
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "RNS nativecall component with native Android/iOS for handling native call ui, when app is not open or open.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,18 +18,29 @@ function withMainActivityDataFix(config) {
18
18
  }
19
19
  });
20
20
 
21
+ imports.forEach(imp => {
22
+ if (!contents.includes(imp)) {
23
+ contents = contents.replace(/package .*/, (match) => `${match}\n${imp}`);
24
+ }
25
+ });
26
+
21
27
  // FIXED: Corrected Kotlin bitwise OR syntax and logic check
28
+ // We check for "navigatingToCall" so this only runs when Answer is tapped
22
29
  const wakeLogic = `super.onCreate(savedInstanceState)
23
- // if (intent?.getBooleanExtra("navigatingToCall", false) == true) {
24
- // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
25
- // setShowWhenLocked(true)
26
- // setTurnScreenOn(true)
27
- // } else {
28
- // window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
29
- // }
30
- // }
30
+ if (intent?.getBooleanExtra("navigatingToCall", false) == true) {
31
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
32
+ setShowWhenLocked(true)
33
+ setTurnScreenOn(true)
34
+ } else {
35
+ window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
36
+ }
31
37
 
32
- `;
38
+ // Remove Keyguard so we jump straight to app (optional but recommended)
39
+ val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as? android.app.KeyguardManager
40
+ keyguardManager?.requestDismissKeyguard(this, null)
41
+ }`;
42
+
43
+
33
44
 
34
45
  if (!contents.includes('setShowWhenLocked')) {
35
46
  contents = contents.replace(/super\.onCreate\(.*\)/, wakeLogic);