在收到通知后从后台启动React Native App

时间:2020-04-28 20:46:54

标签: react-native

我正在处理本机应用程序,我的要求是在收到的通知上启动特定屏幕。

通知在所有状态(例如前景或背景)下都可以正常工作。

我正在使用以下库:

react-navigation
@react-native-firebase/messaging
react-native-push-notification

以下是用于处理通知的代码:

messaging().setBackgroundMessageHandler(async remoteMessage => {
  console.log('Message handled in the background!', remoteMessage);
  let text = {
    title: remoteMessage.data.title,
    body: remoteMessage.data.body,
  }
  notif.cancelAll();
  notif.localNotif(text);
  NavigationService.navigate('Contact', { userName: 'Lucy' })
});

还针对

的通知接收方法编写了导航代码

https://reactnavigation.org/docs/4.x/navigating-without-navigation-prop

我可以看到应用导航到特定屏幕,但未启动应用。

有人可以帮我吗?

0 个答案:

没有答案