如果应用程序关闭,React-Native 深度链接将不起作用(React-Navigation v5)

ver*_*per 5 deep-linking reactjs react-native react-navigation

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

我有一个关于深层链接的问题。如果应用程序被关闭(杀死)并且通过深层链接打开它,它将带我到主屏幕,而不是它必须带我到的屏幕。

这是我的链接配置,根据我在文档(此处)中读到的内容,我将 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.
      }
    }
  };
Run Code Online (Sandbox Code Playgroud)

Ale*_*kin 0

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

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