Someone, please help!

answerCall event is not firing in Android only. When we call displayIncomingCall and the incoming call shows on Android, and when we press the call end button, the endCall event is firing, but when we press the call-accept button, it stays there on the call screen and nothing happens. And the answerCall event is not firing.

Please help, we've tried all the solutions, nothing is working.

And this is my code:

// Register background handler
messaging().setBackgroundMessageHandler(async remoteMessage => {
    console.log('Message handled in the background!', remoteMessage);
    const callUUID = uuid.v4().toLowerCase()
    const number = String(Math.floor(Math.random() * 100000))
  
    RNCallKeep.displayIncomingCall(callUUID, number, number, 'number', false);
    // await Linking.openURL("awesome://");

    DeviceEventEmitter.addListener("answerCall", (payload) => {
        console.log('answerCall', payload); // it doesn't run here
    });
});

AppRegistry.registerComponent(appName, () => App);

2

There are 2 answers

1
Siddhartha Mukherjee On

This very helpful block, it helps me to implement. you can try this

https://blog.theodo.com/2021/03/react-native-incoming-call-ui-callkeep/

0
EmyDuke On
  1. Register your event emitter outside the fcm background messaging class

  2. I had to kill the native UI by calling the endCall method then navigate to the respective screen

messaging().setBackgroundMessageHandler(async remoteMessage => {
  //your call trigger code piece
})

RNCallKeep.addEventListener('answerCall', async ({ callUUID }) => {
   RNCallKeep.endCall(callUUID);
   RNCallKeep.backToForeground();

   RootNavigation.navigate("Call", {callUUID});
});