简体   繁体   English

如何在React Navigation中深层链接到嵌套导航器?

[英]How to deep link to nested navigators in React Navigation?

My navigation structure is as follows: 我的导航结构如下:

const App = () => {
  const prefix = 'test://';
  return <AppNavigator uriPrefix={prefix} />;
};

const AppNavigator = createSwitchNavigator({
  splash: SplashScreen,
  auth: AuthStack,
  main: HomeStack,
});

const AuthStack = createStackNavigator({
  landing: LandingScreen,
  login: {
    screen: LoginScreen,
    path: 'page/login',
  },
  register: {
    screen: RegisterScreen,
    path: 'page/signup',
  },
});

const HomeStack = createStackNavigator({
  home: HomeScreen,
  details: {
    screen: DetailsScreen,
    path: 'details/:assetId',
  },
  upsell: {
    screen: UpsellScreen,
    path: 'page/upsell',
  },
});

My deep linking URI are: 我的深层链接URI是:

test://page/login
test://page/signup
test://details/12345
test://page/upsell

On linking to any one of these URIs, I am always taken to the SplashScreen which is the first screen of my app. 在链接到这些URI中的任何一个时,我总是被带到SplashScreen ,这是我的应用程序的第一个屏幕。 How do I link to nested navigators properly and link to the correct screen? 如何正确链接到嵌套导航器并链接到正确的屏幕?

According to documentation it looks like you also need to set up Android and iOS native part to make it works correctly. 根据文档,您似乎还需要设置Android和iOS本机部分才能使其正常工作。

It is described here: https://reactnavigation.org/docs/en/deep-linking.html#set-up-with-react-native-init-projects 这里描述: https//reactnavigation.org/docs/en/deep-linking.html#set-up-with-react-native-init-projects

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM