当应用退出状态时React Native事件触发

问题描述 投票:0回答:2

我想在收到 fcm 推送通知时、当应用程序关闭(退出状态)但没有事件触发器时在应用程序中触发警报。

我正在使用

  • @react-native-firebase/应用程序
  • @react-native-firebase/消息传递

有什么办法可以在应用程序处于退出状态时触发事件。

我正在使用这个包来报警

  • 反应本机警报通知

前台和后台一切正常。

firebase react-native push-notification firebase-cloud-messaging alarm
2个回答
0
投票

尝试将其添加到根目录的index.js中:

const backgroundHandler= async (message)=>{
If(message){
    console.log(this is the firebase quit state message,
    message)}
    return
}
appregistry.registerheadlesstask(
        'ReactNativeFirebaseMessagingHeadlessTask',
         (message)=>backgroundHandler )

当从 fcm 接收到的对象中没有通知对象时,会发生这种情况。 如果这是您的问题,这是解决此问题的方法


0
投票

我面临同样的问题,我想在应用程序处于退出状态时单击通知将用户重定向到通知屏幕

你能解决这个问题吗?

© www.soinside.com 2019 - 2024. All rights reserved.