rns-nativecall 0.0.8 → 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.
- package/README.md +4 -22
- package/android/src/main/java/com/rnsnativecall/CallMessagingService.kt +12 -0
- package/android/src/main/java/com/rnsnativecall/NativeCallManager.kt +45 -0
- package/app.plugin.js +2 -2
- package/index.js +1 -3
- package/package.json +2 -2
- package/{withRaiidrVoip.js → withNativeCallVoip.js} +24 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RNS Native Call
|
|
2
2
|
|
|
3
|
-
RNS Native Call is a React Native package that provides fully native VoIP call handling on Android and iOS. It supports self-managed calls,
|
|
3
|
+
RNS Native Call is a React Native package that provides fully native VoIP call handling on Android and iOS. It supports self-managed calls, video calls, and allows dismissing native call UI programmatically.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -10,10 +10,8 @@ RNS Native Call is a React Native package that provides fully native VoIP call h
|
|
|
10
10
|
* Support for video and audio calls.
|
|
11
11
|
* Self-managed calls on Android (prevents polluting the device call log).
|
|
12
12
|
* Prevents iOS call log from being saved using `includesCallsInRecents = NO`.
|
|
13
|
-
* Control ringtone per call.
|
|
14
13
|
* Subscribe to call events (accepted, rejected, failed).
|
|
15
14
|
* Cross-platform (Android & iOS) ready.
|
|
16
|
-
* TypeScript types included.
|
|
17
15
|
|
|
18
16
|
---
|
|
19
17
|
|
|
@@ -34,14 +32,12 @@ If you are using **Expo managed workflow**, the package provides a plugin that a
|
|
|
34
32
|
In your `app.json` / `app.config.js`:
|
|
35
33
|
|
|
36
34
|
```js
|
|
37
|
-
import withRaiidrVoip from 'rns-nativecall/withRaiidrVoip';
|
|
38
|
-
|
|
39
35
|
export default {
|
|
40
36
|
expo: {
|
|
41
37
|
name: 'YourApp',
|
|
42
38
|
slug: 'your-app',
|
|
43
39
|
plugins: [
|
|
44
|
-
|
|
40
|
+
"rns-nativecall"
|
|
45
41
|
],
|
|
46
42
|
},
|
|
47
43
|
};
|
|
@@ -78,7 +74,7 @@ cd ios
|
|
|
78
74
|
pod install
|
|
79
75
|
```
|
|
80
76
|
|
|
81
|
-
2. CallKit is automatically used, and call log entries are prevented using:
|
|
77
|
+
2. CallKit is automatically used, so you need to enable it in your project, thats all and call log entries are prevented using:
|
|
82
78
|
|
|
83
79
|
```objc
|
|
84
80
|
config.includesCallsInRecents = NO;
|
|
@@ -102,7 +98,7 @@ const unsubscribe = CallHandler.subscribe(
|
|
|
102
98
|
|
|
103
99
|
// Display an incoming call
|
|
104
100
|
await CallHandler.displayCall(
|
|
105
|
-
'uuid-string',
|
|
101
|
+
'uuid-string', // use uuid.v4();
|
|
106
102
|
'+1234567890',
|
|
107
103
|
'John Doe',
|
|
108
104
|
true, // hasVideo
|
|
@@ -166,20 +162,6 @@ The Expo plugin ensures these are automatically added to `AndroidManifest.xml`.
|
|
|
166
162
|
|
|
167
163
|
---
|
|
168
164
|
|
|
169
|
-
## TypeScript Support
|
|
170
|
-
|
|
171
|
-
Types are included. Example:
|
|
172
|
-
|
|
173
|
-
```ts
|
|
174
|
-
import CallHandler, { CallData, CallAcceptedCallback } from 'rns-nativecall';
|
|
175
|
-
|
|
176
|
-
const onAccept: CallAcceptedCallback = (data: CallData) => {
|
|
177
|
-
console.log('Accepted:', data.callUUID);
|
|
178
|
-
};
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
165
|
## Notes
|
|
184
166
|
|
|
185
167
|
* Android uses `Connection.CAPABILITY_SELF_MANAGED` to prevent calls from showing in the system call log.
|
|
@@ -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/app.plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
////Users/bush/Desktop/Apps/Raiidr/package/app.plugin.js
|
|
2
|
-
const
|
|
2
|
+
const withNativeCallVoip = require('./withNativeCallVoip');
|
|
3
3
|
|
|
4
4
|
module.exports = function (config) {
|
|
5
|
-
return
|
|
5
|
+
return withNativeCallVoip(config);
|
|
6
6
|
};
|
package/index.js
CHANGED
|
@@ -4,8 +4,6 @@ import {
|
|
|
4
4
|
NativeEventEmitter,
|
|
5
5
|
PermissionsAndroid,
|
|
6
6
|
Platform,
|
|
7
|
-
Linking,
|
|
8
|
-
Alert
|
|
9
7
|
} from 'react-native';
|
|
10
8
|
|
|
11
9
|
const { CallModule } = NativeModules;
|
|
@@ -53,7 +51,7 @@ export const CallHandler = {
|
|
|
53
51
|
shouldRing
|
|
54
52
|
);
|
|
55
53
|
} catch (e) {
|
|
56
|
-
console.
|
|
54
|
+
// console.log("Native Call Error:", e);
|
|
57
55
|
return false;
|
|
58
56
|
}
|
|
59
57
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rns-nativecall",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "RNS nativecall component with native Android/iOS for handling native call ui, when app is not open or open.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-native.config.js",
|
|
43
43
|
"README.md",
|
|
44
44
|
"rns-nativecall.podspec",
|
|
45
|
-
"
|
|
45
|
+
"withNativeCallVoip.js"
|
|
46
46
|
],
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react-native": "*",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
///Users/bush/Desktop/Apps/Raiidr/package/withRaiidrVoip.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
|
+
};
|