rns-nativecall 0.5.3 → 0.5.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.
@@ -10,48 +10,41 @@ class AcceptCallActivity : Activity() {
10
10
  override fun onCreate(savedInstanceState: Bundle?) {
11
11
  super.onCreate(savedInstanceState)
12
12
 
13
- // 1. EXTRACT DATA SAFELY
14
13
  val extras = intent.extras
15
14
  val dataMap = mutableMapOf<String, String>()
16
15
  extras?.keySet()?.forEach { key ->
17
- val value = extras.get(key)
18
- if (value != null) {
19
- dataMap[key] = value.toString()
20
- }
16
+ extras.get(key)?.let { dataMap[key] = it.toString() }
21
17
  }
22
18
 
23
19
  val uuid = dataMap["callUuid"]
24
20
 
25
- // 2. STOP RINGING & CLEAR THE SPECIFIC NOTIFICATION
21
+ CallMessagingService.stopBackupTimer(uuid)
22
+ val stopHeadlessIntent = Intent(this, CallHeadlessTask::class.java)
23
+ stopService(stopHeadlessIntent)
24
+
25
+
26
+ // 1. Stop UI/Ringtone immediately
26
27
  NativeCallManager.stopRingtone()
27
28
  val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
28
-
29
29
  if (uuid != null) {
30
- // MATCHING THE NEW HASHCODE LOGIC
31
30
  notificationManager.cancel(uuid.hashCode())
32
- } else {
33
- // Fallback for safety
34
- notificationManager.cancel(101)
35
31
  }
36
32
 
37
- // 3. EMIT EVENT TO REACT NATIVE
38
- CallModule.sendEventToJS("onCallAccepted", dataMap)
39
-
40
- // Ensure the data is available for the JS bridge even if it's just waking up
33
+ // 2. SYNC WITH CALLMODULE: Save data for getInitialCallData()
41
34
  CallModule.setPendingCallData(dataMap)
42
35
 
43
- // 4. LAUNCH OR BRING MAIN APP TO FOREGROUND
36
+ // 3. SYNC WITH CALLMODULE: Emit event for the active Bridge
37
+ CallModule.sendEventToJS("onCallAccepted", dataMap)
38
+
39
+ // 4. Launch Main App
44
40
  val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
45
- if (launchIntent != null) {
46
- launchIntent.apply {
47
- addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
48
- putExtras(extras ?: Bundle())
49
- putExtra("navigatingToCall", true)
50
- }
51
- startActivity(launchIntent)
41
+ launchIntent?.apply {
42
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
43
+ putExtras(extras ?: Bundle())
44
+ putExtra("navigatingToCall", true)
52
45
  }
46
+ startActivity(launchIntent)
53
47
 
54
- // 5. FINISH TRAMPOLINE
55
48
  finish()
56
49
  }
57
50
  }
@@ -4,51 +4,44 @@ import android.content.BroadcastReceiver
4
4
  import android.content.Context
5
5
  import android.content.Intent
6
6
  import android.app.NotificationManager
7
- import android.os.Bundle
8
7
 
9
8
  class CallActionReceiver : BroadcastReceiver() {
10
9
  override fun onReceive(context: Context, intent: Intent) {
11
- // 1. Always stop the ringtone immediately
10
+ val uuid = intent.getStringExtra("EXTRA_CALL_UUID") ?: return
11
+ val action = intent.action ?: return
12
+
13
+ // 1. KILL THE BACKUP TIMER (Stop MessagingService from re-triggering)
14
+ CallMessagingService.stopBackupTimer(uuid)
15
+
16
+ // 2. STOP THE HEADLESS SERVICE (Stop JS from initializing WebRTC)
17
+ val stopHeadlessIntent = Intent(context, CallHeadlessTask::class.java)
18
+ context.stopService(stopHeadlessIntent)
19
+
20
+ // 3. STOP NATIVE UI
12
21
  NativeCallManager.stopRingtone()
13
-
14
- val uuid = intent.getStringExtra("EXTRA_CALL_UUID")
15
-
16
- val action = intent.action
17
-
18
- // 2. Clear the specific notification using the hash code
19
22
  val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
20
- if (uuid != null) {
21
- notificationManager.cancel(uuid.hashCode())
22
- } else {
23
- notificationManager.cancel(101) // Fallback for safety
24
- }
23
+ notificationManager.cancel(uuid.hashCode())
25
24
 
26
- // 3. Handle Actions
27
- // We check for .contains or .startsWith because our actions are "ACTION_REJECT_$uuid"
28
- if (action?.contains("ACTION_ACCEPT") == true || action?.contains("ACTION_SHOW_UI") == true) {
29
- val dataMap = mutableMapOf<String, String>()
30
- intent.extras?.keySet()?.forEach { key ->
31
- intent.extras?.get(key)?.let { dataMap[key] = it.toString() }
32
- }
25
+ val dataMap = mutableMapOf<String, String>()
26
+ intent.extras?.keySet()?.forEach { key ->
27
+ intent.extras?.get(key)?.let { dataMap[key] = it.toString() }
28
+ }
33
29
 
34
- // Store data for the JS Bridge "Holding Gate"
30
+ if (action.contains("ACTION_ACCEPT")) {
35
31
  CallModule.setPendingCallData(dataMap)
36
-
37
- // Emit event for active JS bridge
38
32
  CallModule.sendEventToJS("onCallAccepted", dataMap)
39
33
 
40
- // Bring app to foreground
41
34
  val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)
42
35
  launchIntent?.apply {
43
36
  addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
44
- putExtras(intent.extras ?: Bundle())
37
+ putExtras(intent.extras ?: android.os.Bundle())
45
38
  putExtra("navigatingToCall", true)
46
39
  }
47
40
  context.startActivity(launchIntent)
48
41
 
49
- } else if (action?.contains("ACTION_REJECT") == true) {
50
- // Logic for Reject
51
- CallModule.sendEventToJS("onCallRejected", mapOf("callUuid" to (uuid ?: "")))
42
+ } else if (action.contains("ACTION_REJECT")) {
43
+ // Tell JS call is dead
44
+ CallModule.sendEventToJS("onCallRejected", dataMap)
52
45
  }
53
46
  }
54
47
  }
@@ -21,6 +21,14 @@ class CallMessagingService : FirebaseMessagingService() {
21
21
  companion object {
22
22
  private val handler = Handler(Looper.getMainLooper())
23
23
  private val pendingNotifications = mutableMapOf<String, Runnable>()
24
+
25
+ @JvmStatic
26
+ fun stopBackupTimer(uuid: String) {
27
+ pendingNotifications[uuid]?.let {
28
+ handler.removeCallbacks(it)
29
+ pendingNotifications.remove(uuid)
30
+ }
31
+ }
24
32
  }
25
33
 
26
34
  // Helper to check app state
@@ -76,6 +84,8 @@ class CallMessagingService : FirebaseMessagingService() {
76
84
  }
77
85
  }
78
86
 
87
+
88
+
79
89
  private fun showMissedCallNotification(context: Context, data: Map<String, String>, uuid: String) {
80
90
  val name = data["name"] ?: "Unknown"
81
91
  val callType = data["callType"] ?: "video"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
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",