|
1 | 1 | # react-native-incoming-call |
2 | 2 |
|
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. |
4 | 4 |
|
5 | 5 | 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. |
6 | 6 |
|
@@ -36,10 +36,28 @@ IncomingCall.dismiss(); |
36 | 36 | // Listen to cancel and answer call events |
37 | 37 | useEffect(() => { |
38 | 38 | 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 | + }); |
43 | 61 | } |
44 | 62 | }, []); |
45 | 63 | ``` |
0 commit comments