rns-nativecall 0.5.3 → 0.5.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.
@@ -10,48 +10,36 @@ 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
+ // 1. Stop UI/Ringtone immediately
26
22
  NativeCallManager.stopRingtone()
27
23
  val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
28
-
29
24
  if (uuid != null) {
30
- // MATCHING THE NEW HASHCODE LOGIC
31
25
  notificationManager.cancel(uuid.hashCode())
32
- } else {
33
- // Fallback for safety
34
- notificationManager.cancel(101)
35
26
  }
36
27
 
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
28
+ // 2. SYNC WITH CALLMODULE: Save data for getInitialCallData()
41
29
  CallModule.setPendingCallData(dataMap)
42
30
 
43
- // 4. LAUNCH OR BRING MAIN APP TO FOREGROUND
31
+ // 3. SYNC WITH CALLMODULE: Emit event for the active Bridge
32
+ CallModule.sendEventToJS("onCallAccepted", dataMap)
33
+
34
+ // 4. Launch Main App
44
35
  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)
36
+ launchIntent?.apply {
37
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
38
+ putExtras(extras ?: Bundle())
39
+ putExtra("navigatingToCall", true)
52
40
  }
41
+ startActivity(launchIntent)
53
42
 
54
- // 5. FINISH TRAMPOLINE
55
43
  finish()
56
44
  }
57
45
  }
@@ -8,47 +8,43 @@ import android.os.Bundle
8
8
 
9
9
  class CallActionReceiver : BroadcastReceiver() {
10
10
  override fun onReceive(context: Context, intent: Intent) {
11
- // 1. Always stop the ringtone immediately
12
11
  NativeCallManager.stopRingtone()
13
12
 
13
+ val extras = intent.extras
14
14
  val uuid = intent.getStringExtra("EXTRA_CALL_UUID")
15
-
16
15
  val action = intent.action
17
16
 
18
- // 2. Clear the specific notification using the hash code
19
17
  val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
20
18
  if (uuid != null) {
21
19
  notificationManager.cancel(uuid.hashCode())
22
- } else {
23
- notificationManager.cancel(101) // Fallback for safety
24
20
  }
25
21
 
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
- }
22
+ val dataMap = mutableMapOf<String, String>()
23
+ extras?.keySet()?.forEach { key ->
24
+ extras.get(key)?.let { dataMap[key] = it.toString() }
25
+ }
33
26
 
34
- // Store data for the JS Bridge "Holding Gate"
27
+ // Match the logic in your CallModule for Answer vs Reject
28
+ if (action?.contains("ACTION_ACCEPT") == true) {
29
+ // Save data for cold-start polling (getInitialCallData)
35
30
  CallModule.setPendingCallData(dataMap)
36
-
37
- // Emit event for active JS bridge
31
+
32
+ // Emit to active bridge
38
33
  CallModule.sendEventToJS("onCallAccepted", dataMap)
39
34
 
40
- // Bring app to foreground
35
+ // Open the app
41
36
  val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)
42
37
  launchIntent?.apply {
43
38
  addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
44
- putExtras(intent.extras ?: Bundle())
39
+ putExtras(extras ?: Bundle())
45
40
  putExtra("navigatingToCall", true)
46
41
  }
47
42
  context.startActivity(launchIntent)
48
43
 
49
44
  } else if (action?.contains("ACTION_REJECT") == true) {
50
- // Logic for Reject
51
- CallModule.sendEventToJS("onCallRejected", mapOf("callUuid" to (uuid ?: "")))
45
+ // Only send the event. Rejection usually doesn't need setPendingCallData
46
+ // as we don't open the app.
47
+ CallModule.sendEventToJS("onCallRejected", dataMap)
52
48
  }
53
49
  }
54
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
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",