rns-nativecall 0.5.2 → 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
|
-
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
|
31
|
+
|
|
32
|
+
// Emit to active bridge
|
|
38
33
|
CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
39
34
|
|
|
40
|
-
//
|
|
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(
|
|
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
|
-
//
|
|
51
|
-
|
|
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
|
}
|
|
@@ -79,6 +79,7 @@ object NativeCallManager {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
val builder = NotificationCompat.Builder(context, CALL_CHANNEL_ID)
|
|
82
|
+
.setSmallIcon(context.applicationInfo.icon)
|
|
82
83
|
.setContentTitle("Incoming $callType call")
|
|
83
84
|
.setContentText(name)
|
|
84
85
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
package/package.json
CHANGED