rns-nativecall 0.6.3 → 0.6.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.
|
@@ -13,70 +13,57 @@ class AcceptCallActivity : Activity() {
|
|
|
13
13
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
14
14
|
super.onCreate(savedInstanceState)
|
|
15
15
|
|
|
16
|
-
// Wake + lock flags
|
|
17
16
|
window.addFlags(
|
|
18
17
|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
19
18
|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
|
|
20
|
-
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
21
|
-
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
|
|
19
|
+
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
22
20
|
)
|
|
23
21
|
|
|
24
|
-
// Optionally dismiss keyguard
|
|
25
22
|
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
|
26
23
|
keyguardManager.requestDismissKeyguard(this, null)
|
|
27
24
|
|
|
28
25
|
processCallIntent(intent)
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
override fun onNewIntent(intent: Intent) {
|
|
32
|
-
super.onNewIntent(intent)
|
|
33
|
-
setIntent(intent)
|
|
34
|
-
processCallIntent(intent)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
28
|
private fun processCallIntent(intent: Intent) {
|
|
38
29
|
NativeCallManager.stopRingtone()
|
|
39
30
|
|
|
40
31
|
val extras = intent.extras
|
|
41
32
|
val uuid = extras?.getString("callUuid")
|
|
42
|
-
val name = extras?.getString("name") ?: "Someone"
|
|
43
|
-
val callType = extras?.getString("callType") ?: "audio"
|
|
44
33
|
|
|
45
34
|
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
46
35
|
uuid?.let { notificationManager.cancel(it.hashCode()) }
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (CallModule.isReady()) {
|
|
54
|
-
CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
55
|
-
openMainApp(extras)
|
|
56
|
-
finish()
|
|
57
|
-
} else {
|
|
58
|
-
CallModule.setPendingCallData("onCallAccepted_pending", dataMap)
|
|
59
|
-
if (uuid != null) {
|
|
60
|
-
NativeCallManager.connecting(this, uuid, name, callType)
|
|
61
|
-
}
|
|
62
|
-
// Register callback to auto‑open app once RN is ready
|
|
63
|
-
CallModule.registerOnReadyCallback {
|
|
64
|
-
runOnUiThread {
|
|
65
|
-
openMainApp(extras)
|
|
66
|
-
finish()
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
37
|
+
// ✅ WE STOP SENDING THE JS EVENT HERE.
|
|
38
|
+
// Instead, we pass the intent to MainActivity with a specific ACTION.
|
|
39
|
+
openMainApp(extras)
|
|
40
|
+
finish()
|
|
70
41
|
}
|
|
71
42
|
|
|
72
|
-
// ✅ Now a proper member function
|
|
73
43
|
private fun openMainApp(extras: Bundle?) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
44
|
+
try {
|
|
45
|
+
// Get the actual MainActivity class name (e.g., com.yourapp.MainActivity)
|
|
46
|
+
val mainActivityClassName = "${packageName}.MainActivity"
|
|
47
|
+
|
|
48
|
+
val intent = Intent().apply {
|
|
49
|
+
setClassName(packageName, mainActivityClassName)
|
|
50
|
+
action = "com.rnsnativecall.ACTION_ANSWER"
|
|
51
|
+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
52
|
+
|
|
53
|
+
// Ensure extras are carried over
|
|
54
|
+
extras?.let { putExtras(it) }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
startActivity(intent)
|
|
58
|
+
} catch (e: Exception) {
|
|
59
|
+
// Fallback: If explicit mapping fails, try the launch intent but force the action
|
|
60
|
+
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
|
|
61
|
+
launchIntent?.apply {
|
|
62
|
+
action = "com.rnsnativecall.ACTION_ANSWER"
|
|
63
|
+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
64
|
+
extras?.let { putExtras(it) }
|
|
65
|
+
startActivity(this)
|
|
66
|
+
}
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
|
-
}
|
|
69
|
+
}
|
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -4,34 +4,59 @@ const { withAndroidManifest, withInfoPlist, withPlugins, withMainActivity } = re
|
|
|
4
4
|
function withMainActivityDataFix(config) {
|
|
5
5
|
return withMainActivity(config, (config) => {
|
|
6
6
|
let contents = config.modResults.contents;
|
|
7
|
+
|
|
8
|
+
// Ensure imports exist
|
|
7
9
|
if (!contents.includes('import android.content.Intent')) {
|
|
8
10
|
contents = contents.replace(/package .*/, (match) => `${match}\n\nimport android.content.Intent`);
|
|
9
11
|
}
|
|
10
12
|
if (!contents.includes('import android.os.Bundle')) {
|
|
11
13
|
contents = contents.replace(/package .*/, (match) => `${match}\n\nimport android.os.Bundle`);
|
|
12
14
|
}
|
|
15
|
+
|
|
13
16
|
const onNewIntentCode = `
|
|
14
17
|
override fun onNewIntent(intent: Intent) {
|
|
15
18
|
super.onNewIntent(intent)
|
|
16
19
|
setIntent(intent)
|
|
20
|
+
|
|
21
|
+
// Check for the specific Answer Action
|
|
22
|
+
val isAnswerAction = intent.action == "com.rnsnativecall.ACTION_ANSWER"
|
|
23
|
+
|
|
17
24
|
val dataMap = mutableMapOf<String, String>()
|
|
18
25
|
intent.extras?.keySet()?.forEach { key ->
|
|
19
26
|
dataMap[key] = intent.extras?.get(key)?.toString() ?: ""
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
|
|
29
|
+
// FIRE if it's the answer action, even if extras are slim
|
|
30
|
+
if (isAnswerAction) {
|
|
31
|
+
com.rnsnativecall.CallModule.setPendingCallData("onCallAccepted_pending", dataMap)
|
|
23
32
|
com.rnsnativecall.CallModule.sendEventToJS("onCallAccepted", dataMap)
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
`;
|
|
36
|
+
|
|
27
37
|
const onCreateCode = `
|
|
28
38
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
29
39
|
super.onCreate(savedInstanceState)
|
|
30
|
-
|
|
40
|
+
|
|
41
|
+
val isAnswerAction = intent.action == "com.rnsnativecall.ACTION_ANSWER"
|
|
42
|
+
|
|
43
|
+
// Logic for Cold Start (App was dead, user answered)
|
|
44
|
+
if (isAnswerAction) {
|
|
45
|
+
val dataMap = mutableMapOf<String, String>()
|
|
46
|
+
intent.extras?.keySet()?.forEach { key ->
|
|
47
|
+
dataMap[key] = intent.extras?.get(key)?.toString() ?: ""
|
|
48
|
+
}
|
|
49
|
+
com.rnsnativecall.CallModule.setPendingCallData(dataMap)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Move to back if it's a background wake (FCM) and NOT an answer click
|
|
53
|
+
if (intent.getBooleanExtra("background_wake", false) && !isAnswerAction) {
|
|
31
54
|
moveTaskToBack(true)
|
|
32
55
|
}
|
|
33
56
|
}
|
|
34
57
|
`;
|
|
58
|
+
|
|
59
|
+
// Inject codes
|
|
35
60
|
if (!contents.includes('override fun onNewIntent')) {
|
|
36
61
|
const lastBraceIndex = contents.lastIndexOf('}');
|
|
37
62
|
contents = contents.slice(0, lastBraceIndex) + onNewIntentCode + contents.slice(lastBraceIndex);
|
|
@@ -40,6 +65,7 @@ function withMainActivityDataFix(config) {
|
|
|
40
65
|
const lastBraceIndex = contents.lastIndexOf('}');
|
|
41
66
|
contents = contents.slice(0, lastBraceIndex) + onCreateCode + contents.slice(lastBraceIndex);
|
|
42
67
|
}
|
|
68
|
+
|
|
43
69
|
config.modResults.contents = contents;
|
|
44
70
|
return config;
|
|
45
71
|
});
|