rns-nativecall 0.1.0 → 0.1.1
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.rnsnativecall
|
|
2
|
+
|
|
3
|
+
import com.google.firebase.messaging.FirebaseMessagingService
|
|
4
|
+
import com.google.firebase.messaging.RemoteMessage
|
|
5
|
+
|
|
6
|
+
class CallMessagingService : FirebaseMessagingService() {
|
|
7
|
+
|
|
8
|
+
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
|
9
|
+
// Directly forward to your native call manager
|
|
10
|
+
NativeCallManager.handleIncomingPush(applicationContext, remoteMessage.data)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package com.rnsnativecall
|
|
2
|
+
|
|
3
|
+
import android.content.ComponentName
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.net.Uri
|
|
6
|
+
import android.os.Bundle
|
|
7
|
+
import android.telecom.PhoneAccountHandle
|
|
8
|
+
import android.telecom.TelecomManager
|
|
9
|
+
|
|
10
|
+
object NativeCallManager {
|
|
11
|
+
|
|
12
|
+
fun handleIncomingPush(context: Context, data: Map<String, String>) {
|
|
13
|
+
val uuid = data["callId"] ?: return
|
|
14
|
+
val handle = data["from"] ?: "Unknown"
|
|
15
|
+
val name = data["name"] ?: handle
|
|
16
|
+
val hasVideo = data["hasVideo"]?.toBoolean() ?: false
|
|
17
|
+
val playRing = data["playRing"]?.toBoolean() ?: true
|
|
18
|
+
|
|
19
|
+
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
|
20
|
+
val phoneAccountHandle = getPhoneAccountHandle(context)
|
|
21
|
+
|
|
22
|
+
val extras =
|
|
23
|
+
Bundle().apply {
|
|
24
|
+
putParcelable(
|
|
25
|
+
TelecomManager.EXTRA_INCOMING_CALL_ADDRESS,
|
|
26
|
+
Uri.fromParts("sip", handle, null)
|
|
27
|
+
)
|
|
28
|
+
putString("EXTRA_CALL_UUID", uuid)
|
|
29
|
+
putString("EXTRA_CALL_SUBJECT", name)
|
|
30
|
+
putBoolean("EXTRA_PLAY_RING", playRing)
|
|
31
|
+
putBoolean("EXTRA_START_CALL_WITH_VIDEO_STATE", hasVideo)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
telecomManager.addNewIncomingCall(phoneAccountHandle, extras)
|
|
36
|
+
} catch (e: Exception) {
|
|
37
|
+
e.printStackTrace()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private fun getPhoneAccountHandle(context: Context): PhoneAccountHandle {
|
|
42
|
+
val componentName = ComponentName(context, MyConnectionService::class.java)
|
|
43
|
+
return PhoneAccountHandle(componentName, "${context.packageName}.voip")
|
|
44
|
+
}
|
|
45
|
+
}
|
package/package.json
CHANGED
package/withNativeCallVoip.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
///Users/bush/Desktop/Apps/Raiidr/package/withNativeCallVoip.js
|
|
2
1
|
const { withAndroidManifest, withInfoPlist, withPlugins } = require('@expo/config-plugins');
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -27,13 +26,14 @@ function withAndroidConfig(config) {
|
|
|
27
26
|
const application = manifest.manifest.application[0];
|
|
28
27
|
application.service = application.service || [];
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
const
|
|
29
|
+
// MyConnectionService
|
|
30
|
+
const connectionServiceName = 'com.rnsnativecall.MyConnectionService';
|
|
31
|
+
const existingConnectionService = application.service.find((s) => s.$['android:name'] === connectionServiceName);
|
|
32
32
|
|
|
33
|
-
if (!
|
|
33
|
+
if (!existingConnectionService) {
|
|
34
34
|
application.service.push({
|
|
35
35
|
$: {
|
|
36
|
-
'android:name':
|
|
36
|
+
'android:name': connectionServiceName,
|
|
37
37
|
'android:permission': 'android.permission.BIND_CONNECTION_SERVICE',
|
|
38
38
|
'android:exported': 'true',
|
|
39
39
|
},
|
|
@@ -45,6 +45,24 @@ function withAndroidConfig(config) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// CallMessagingService (FCM)
|
|
49
|
+
const fcmServiceName = 'com.rnsnativecall.CallMessagingService';
|
|
50
|
+
const existingFCMService = application.service.find((s) => s.$['android:name'] === fcmServiceName);
|
|
51
|
+
|
|
52
|
+
if (!existingFCMService) {
|
|
53
|
+
application.service.push({
|
|
54
|
+
$: {
|
|
55
|
+
'android:name': fcmServiceName,
|
|
56
|
+
'android:exported': 'false',
|
|
57
|
+
},
|
|
58
|
+
'intent-filter': [
|
|
59
|
+
{
|
|
60
|
+
action: [{ $: { 'android:name': 'com.google.firebase.MESSAGING_EVENT' } }]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
48
66
|
return config;
|
|
49
67
|
});
|
|
50
68
|
}
|
|
@@ -68,7 +86,6 @@ function withIosConfig(config) {
|
|
|
68
86
|
});
|
|
69
87
|
|
|
70
88
|
// 2. Dynamic Microphone Description
|
|
71
|
-
// config.name pulls the name from the user's app.json automatically
|
|
72
89
|
const appName = config.name || 'this app';
|
|
73
90
|
infoPlist.NSMicrophoneUsageDescription =
|
|
74
91
|
infoPlist.NSMicrophoneUsageDescription || `Allow ${appName} to access your microphone for calls.`;
|
|
@@ -82,4 +99,4 @@ module.exports = (config) => {
|
|
|
82
99
|
withAndroidConfig,
|
|
83
100
|
withIosConfig,
|
|
84
101
|
]);
|
|
85
|
-
};
|
|
102
|
+
};
|