gpt4 book ai didi

react-native - 应用程序在前台或关闭时收到推送通知时的正确导航方式

转载 作者:行者123 更新时间:2023-12-04 14:54:30 25 4
gpt4 key购买 nike

这是所有使用 React 导航的人的普遍问题,以下是我的导航结构

export const createRootNavigator = (signedIn = false) => {
return StackNavigator({
Login: screen: Login,
Welcome: screen: Welcome,
Loading: screen: Loading,
SignedIn: screen: SignedIn,
});
};

export const SignedIn = TabNavigator ({
Home: screen: HomeNavigation,
FeedBack: screen: FeedBackNavigation,
Search: screen: SearchNavigation,
Me: screen: ProfileNavigation,
});

我正在使用“react-native-fcm”在应用程序处于前台或关闭时接收通知。我应该如何构建代码以在收到通知后导航到特定屏幕?
我应该在每个屏幕上订阅 onNotification 然后导航到特定屏幕还是将它放在一个集中的地方?以前有人解决过这个问题吗?示例代码会很棒

软件版本:

react 导航 1.0.0-beta.26

react 原生 0.49.3

最佳答案

要实现此行为,您需要实现 Deep Linking到您的应用程序。详细示例和解释可以在 react-navigation docs 中找到。并在 this issue .

来自 React-Native 文档

Linking gives you a general interface to interact with both incoming and outgoing app links.



来自 react-navigation文档

Deep linking

In this guide we will set up our app to handle external URIs. Let's suppose that we want a URI like mychat://chat/Eric to open our app and link straight into a chat screen for some user named "Eric".



来自 react-native-fcm问题

You can use the notification listener to grab notification details and use your router (in my case react-native-router-flux) to trigger the desired action and show the right view.

关于react-native - 应用程序在前台或关闭时收到推送通知时的正确导航方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49094140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com