Skip to content

Commit 4ab9305

Browse files
committed
v1.2.0
1 parent 5def198 commit 4ab9305

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-native-incoming-call
22

3-
> React Native module to display incoming call activity, best result when using with firebase background messaging. Only for Android since iOS we have VoIP.
3+
> React Native module to display custom incoming call activity, best result when using with firebase background messaging. Only for Android since iOS we have VoIP.
44
55
Yes I heard you could use **self managed ConnectionService** thing. But since I'm not an Android expert, this is a solution I found acceptable.
66

@@ -36,10 +36,28 @@ IncomingCall.dismiss();
3636
// Listen to cancel and answer call events
3737
useEffect(() => {
3838
if (Platform.OS === "android") {
39-
// Handle end call action. Should call IncomingCall.dismiss() and other exit room actions.
40-
DeviceEventEmitter.addListener("endCall", payload => {});
41-
// Handle answer call action. Should navigate user to call screen.
42-
DeviceEventEmitter.addListener("answerCall", payload => {});
39+
/**
40+
* App in background or killed state, if user press answer button
41+
* IncomingCall open app and put payload to getLaunchParameters
42+
* You could start the call action here.
43+
* End call action in this case not supported yet.
44+
*/
45+
const payload = await IncomingCall.getLaunchParameters();
46+
console.log('launchParameters', payload);
47+
IncomingCall.clearLaunchParameters();
48+
if (payload) {
49+
// Start call here
50+
}
51+
52+
/**
53+
* App in foreground: listen to call events and determine what to do next
54+
*/
55+
DeviceEventEmitter.addListener("endCall", payload => {
56+
// End call action here
57+
});
58+
DeviceEventEmitter.addListener("answerCall", payload => {
59+
// Start call action here
60+
});
4361
}
4462
}, []);
4563
```

android/src/main/java/com/incomingcall/UnlockScreenActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private void acceptDialing() {
120120
params.putBoolean("done", true);
121121
params.putString("uuid", uuid);
122122

123-
if (isAppOnForeground()) {
123+
if (IncomingCallModule.reactContext.hasCurrentActivity() && isAppOnForeground()) {
124124
// App in foreground, send event for app to listen
125125
sendEvent("answerCall", params);
126126
} else {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-incoming-call",
33
"title": "React Native Incoming Call",
4-
"version": "1.1.0",
4+
"version": "1.2.0",
55
"description": "React Native module to display incoming call activity. Only for Android since iOS we have VoIP.",
66
"main": "index.js",
77
"scripts": {

0 commit comments

Comments
 (0)