'React Native CallKeep : answerCall' CallKeep Listener occasionally does not run, when answering call while app is terminated/background

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);


Solution 1:[1]

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/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Siddhartha Mukherjee