React Native CallKeep:answerCall'在应用程序终止/后台接听电话时,CallKeep Listener 有时不会运行

发布于 2025-01-20 21:47:40 字数 10 浏览 5 评论 0原文

有人请帮忙!

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简单 2025-01-27 21:47:40

这个非常有用的块,它帮助我实现。你可以试试这个

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

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/

两仪 2025-01-27 21:47:40
  1. 在FCM背景消息类之外注册您的活动发射器

  2. 我必须通过调用endCall方法杀死本机UI,然后导航到相应的屏幕

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

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文