如果应用关闭,则无法进行React-Native深度链接React-Navigation v5

问题描述

我已经使用React Navigation V5为我的应用实现了深层链接

我对深度链接有疑问。如果该应用已关闭(已终止)并通过深层链接打开,它将带我进入主屏幕,而不是必须带我进入的屏幕。

这是我的链接配置,根据我在文档(here)中所读的内容,我正在将URL从getinitialUrl函数传递给订阅,这里 const onReceiveURL = ({ url }) => listener(url); 它应该将URL解析为有效的导航状态,然后转到需要的屏幕。不过,我可能会误认订阅的工作方式。

感谢您的帮助,谢谢!

const linking = {
    prefixes: ['appName://','app.appName.com://',APP_WEB_DOMAIN],async getinitialURL() {
      // Check if app was opened from a deep link
      const url = await Linking.getinitialURL();
      if (url != null) {
        return url;
      }
    },subscribe(listener) {
      const onReceiveURL = ({ url }) => listener(url);

      Linking.addEventListener('url',onReceiveURL);

      return () => {
        // Clean up the event listener
        Linking.removeEventListener('url',onReceiveURL);
      };
    },config: {
      screens: {
        SignInScreen: 'login',UnauthenticatedStack: '',TrackListScreen: 'playlist/:id/' //:id gets parsed as a string,you have to specify it if you want a number.
      }
    }
  };

解决方法

由于react-native-splash-screen中的错误,我遇到了类似的问题(推送通知中的深层链接)

在这里https://github.com/spencercarli/react-native-splash-screen-demo/pull/11