rns-nativecall 1.0.0 → 1.0.2
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.
|
@@ -20,32 +20,35 @@ class CallActionReceiver : BroadcastReceiver() {
|
|
|
20
20
|
intent.extras?.get(key)?.let { fullDataMap[key] = it.toString() }
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// --- HANDLE
|
|
24
|
-
if (action == "
|
|
23
|
+
// --- HANDLE ANSWER ---
|
|
24
|
+
if (action == "ACTION_ANSWER") {
|
|
25
|
+
// 1. Kill the ringing notification and service immediately
|
|
25
26
|
NativeCallManager.dismissIncomingCall(context, uuid)
|
|
26
|
-
CallForegroundService.stop(context)
|
|
27
27
|
|
|
28
|
+
// 2. Queue or Send the accept event
|
|
28
29
|
if (CallModule.isReady()) {
|
|
29
|
-
CallModule.sendEventToJS("
|
|
30
|
+
CallModule.sendEventToJS("onCallAccepted", fullDataMap)
|
|
30
31
|
} else {
|
|
31
|
-
CallModule.setPendingCallData("
|
|
32
|
+
CallModule.setPendingCallData("onCallAccepted_pending", fullDataMap)
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
// 3. Bring the app to the front
|
|
36
|
+
launchApp(context, intent.extras)
|
|
34
37
|
collapseNotificationShade(context)
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
// --- HANDLE
|
|
38
|
-
if (action == "
|
|
40
|
+
// --- HANDLE REJECT ---
|
|
41
|
+
if (action == "ACTION_REJECT") {
|
|
42
|
+
// This kills the Notification AND the Foreground Service (via our updated Manager)
|
|
39
43
|
NativeCallManager.dismissIncomingCall(context, uuid)
|
|
40
44
|
|
|
45
|
+
// Notify JS
|
|
41
46
|
if (CallModule.isReady()) {
|
|
42
|
-
CallModule.sendEventToJS("
|
|
47
|
+
CallModule.sendEventToJS("onCallRejected", fullDataMap)
|
|
43
48
|
} else {
|
|
44
|
-
CallModule.setPendingCallData("
|
|
49
|
+
CallModule.setPendingCallData("onCallRejected_pending", fullDataMap)
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
// This will open your app and the system usually collapses the shade automatically
|
|
48
|
-
launchApp(context, intent.extras)
|
|
49
52
|
collapseNotificationShade(context)
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -18,8 +18,7 @@ class CallForegroundService : Service() {
|
|
|
18
18
|
private var unlockReceiver: UnlockReceiver? = null // Store reference for unregistering
|
|
19
19
|
|
|
20
20
|
companion object {
|
|
21
|
-
private const val
|
|
22
|
-
private const val CHANNEL_ID = "incoming_call_service"
|
|
21
|
+
private const val CHANNEL_ID = "CALL_CHANNEL_V10_URGENT"
|
|
23
22
|
|
|
24
23
|
fun stop(context: Context) {
|
|
25
24
|
val intent = Intent(context, CallForegroundService::class.java)
|
|
@@ -62,10 +61,10 @@ class CallForegroundService : Service() {
|
|
|
62
61
|
NotificationCompat
|
|
63
62
|
.Builder(this, CHANNEL_ID)
|
|
64
63
|
.setContentTitle(name)
|
|
65
|
-
.setContentText("
|
|
64
|
+
.setContentText("Connecting...")
|
|
66
65
|
.setSmallIcon(applicationInfo.icon)
|
|
67
|
-
.
|
|
68
|
-
.
|
|
66
|
+
.setPriority(NotificationCompat.PRIORITY_MIN)
|
|
67
|
+
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
|
69
68
|
.setOngoing(true)
|
|
70
69
|
.build()
|
|
71
70
|
|
|
@@ -131,7 +130,7 @@ class CallForegroundService : Service() {
|
|
|
131
130
|
NotificationChannel(
|
|
132
131
|
CHANNEL_ID,
|
|
133
132
|
"Call Service",
|
|
134
|
-
NotificationManager.
|
|
133
|
+
NotificationManager.IMPORTANCE_HIGH,
|
|
135
134
|
).apply {
|
|
136
135
|
description = "Incoming call connection state"
|
|
137
136
|
setSound(null, null)
|
|
@@ -15,11 +15,7 @@ import androidx.core.app.NotificationCompat
|
|
|
15
15
|
import androidx.core.app.Person
|
|
16
16
|
|
|
17
17
|
object NativeCallManager {
|
|
18
|
-
|
|
19
|
-
// because the system NotificationManager handles the sound.
|
|
20
|
-
|
|
21
|
-
// Incrementing version to V3 to force fresh channel settings on the device
|
|
22
|
-
const val channelId = "CALL_CHANNEL_V9_URGENT"
|
|
18
|
+
const val channelId = "CALL_CHANNEL_V10_URGENT"
|
|
23
19
|
private var currentCallData: Map<String, String>? = null
|
|
24
20
|
|
|
25
21
|
fun getCurrentCallData(): Map<String, String>? = currentCallData
|
|
@@ -129,10 +125,6 @@ object NativeCallManager {
|
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
|
|
132
|
-
/**
|
|
133
|
-
* Stop the ringtone by canceling the notification itself.
|
|
134
|
-
* The system manages the sound, so when the notification dies, the sound dies.
|
|
135
|
-
*/
|
|
136
128
|
fun dismissIncomingCall(
|
|
137
129
|
context: Context,
|
|
138
130
|
uuid: String?,
|
|
@@ -190,7 +182,6 @@ object NativeCallManager {
|
|
|
190
182
|
notificationManager.notify(uuid.hashCode(), builder.build())
|
|
191
183
|
}
|
|
192
184
|
|
|
193
|
-
// Deprecated manual method - kept for signature compatibility but does nothing
|
|
194
185
|
fun stopRingtone() {
|
|
195
186
|
// No-op: Sound is now managed by the Notification Channel life-cycle
|
|
196
187
|
}
|