rns-nativecall 0.6.4 → 0.6.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.
|
@@ -13,6 +13,7 @@ class AcceptCallActivity : Activity() {
|
|
|
13
13
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
14
14
|
super.onCreate(savedInstanceState)
|
|
15
15
|
|
|
16
|
+
// Ensure we show over the lockscreen
|
|
16
17
|
window.addFlags(
|
|
17
18
|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
18
19
|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
|
|
@@ -34,19 +35,27 @@ class AcceptCallActivity : Activity() {
|
|
|
34
35
|
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
35
36
|
uuid?.let { notificationManager.cancel(it.hashCode()) }
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
val dataMap = mutableMapOf<String, String>()
|
|
39
|
+
extras?.keySet()?.forEach { key ->
|
|
40
|
+
extras.get(key)?.let { dataMap[key] = it.toString() }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 1. Set the data for JS (Cold start support)
|
|
44
|
+
CallModule.setPendingCallData("onCallAccepted_pending", dataMap)
|
|
45
|
+
|
|
46
|
+
// 2. Fire event immediately if JS is alive
|
|
47
|
+
if (CallModule.isReady()) {
|
|
48
|
+
CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 3. Bring the Main App to the front
|
|
39
52
|
openMainApp(extras)
|
|
40
53
|
finish()
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
private fun openMainApp(extras: Bundle?) {
|
|
44
|
-
// We look for the MainActivity class specifically
|
|
45
57
|
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
|
|
46
58
|
launchIntent?.apply {
|
|
47
|
-
// ✅ CRITICAL: Identify this as a deliberate "Answer" click
|
|
48
|
-
action = "com.rnsnativecall.ACTION_ANSWER"
|
|
49
|
-
|
|
50
59
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
51
60
|
putExtras(extras ?: Bundle())
|
|
52
61
|
startActivity(this)
|
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -5,31 +5,10 @@ function withMainActivityDataFix(config) {
|
|
|
5
5
|
return withMainActivity(config, (config) => {
|
|
6
6
|
let contents = config.modResults.contents;
|
|
7
7
|
|
|
8
|
-
// Ensure imports exist
|
|
9
|
-
if (!contents.includes('import android.content.Intent')) {
|
|
10
|
-
contents = contents.replace(/package .*/, (match) => `${match}\n\nimport android.content.Intent`);
|
|
11
|
-
}
|
|
12
|
-
if (!contents.includes('import android.os.Bundle')) {
|
|
13
|
-
contents = contents.replace(/package .*/, (match) => `${match}\n\nimport android.os.Bundle`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
8
|
const onNewIntentCode = `
|
|
17
9
|
override fun onNewIntent(intent: Intent) {
|
|
18
10
|
super.onNewIntent(intent)
|
|
19
11
|
setIntent(intent)
|
|
20
|
-
|
|
21
|
-
// Only fire JS event if the user actually pressed "Answer"
|
|
22
|
-
val isAnswerAction = intent.action == "com.rnsnativecall.ACTION_ANSWER"
|
|
23
|
-
|
|
24
|
-
val dataMap = mutableMapOf<String, String>()
|
|
25
|
-
intent.extras?.keySet()?.forEach { key ->
|
|
26
|
-
dataMap[key] = intent.extras?.get(key)?.toString() ?: ""
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (dataMap.isNotEmpty() && isAnswerAction) {
|
|
30
|
-
com.rnsnativecall.CallModule.setPendingCallData(dataMap)
|
|
31
|
-
com.rnsnativecall.CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
32
|
-
}
|
|
33
12
|
}
|
|
34
13
|
`;
|
|
35
14
|
|
|
@@ -37,25 +16,12 @@ function withMainActivityDataFix(config) {
|
|
|
37
16
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
38
17
|
super.onCreate(savedInstanceState)
|
|
39
18
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// Logic for Cold Start (App was dead, user answered)
|
|
43
|
-
if (isAnswerAction) {
|
|
44
|
-
val dataMap = mutableMapOf<String, String>()
|
|
45
|
-
intent.extras?.keySet()?.forEach { key ->
|
|
46
|
-
dataMap[key] = intent.extras?.get(key)?.toString() ?: ""
|
|
47
|
-
}
|
|
48
|
-
com.rnsnativecall.CallModule.setPendingCallData(dataMap)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Move to back if it's a background wake (FCM) and NOT an answer click
|
|
52
|
-
if (intent.getBooleanExtra("background_wake", false) && !isAnswerAction) {
|
|
19
|
+
// If background wake from FCM, move to back to let LockScreen UI show
|
|
20
|
+
if (intent.getBooleanExtra("background_wake", false)) {
|
|
53
21
|
moveTaskToBack(true)
|
|
54
22
|
}
|
|
55
23
|
}
|
|
56
24
|
`;
|
|
57
|
-
|
|
58
|
-
// Inject codes
|
|
59
25
|
if (!contents.includes('override fun onNewIntent')) {
|
|
60
26
|
const lastBraceIndex = contents.lastIndexOf('}');
|
|
61
27
|
contents = contents.slice(0, lastBraceIndex) + onNewIntentCode + contents.slice(lastBraceIndex);
|