简体   繁体   English

React Native - 当应用程序不在后台(Android,iOS)时,深度链接不起作用

[英]React Native - Deep linking is not working when app is not in background (Android, iOS)

  • if app in background如果应用在后台

    specific screen will open.特定屏幕将打开。

  • if app is not in background or kill the app如果应用程序不在后台或终止应用程序

    it will show first screen only.它只会显示第一个屏幕。

Linking.getInitialURL() is return null Linking.getInitialURL() 返回 null

If you want to do redirection in case of the app is kill or not yet launch, find the below simple solution:如果您想在应用程序被终止或尚未启动的情况下进行重定向,请找到以下简单的解决方案:

// Don't forget to import 

    import {
      Linking
    } from 'react-native';



  useEffect(() => {
    const getAsyncURL = async () => {
      const initialUrl = await Linking.getInitialURL();
      if (initialUrl != undefined && initialUrl != null){
         // Handle initialURL as per your response and open a specific screen using navigation
      }
    };

    getAsyncURL();
  }, []);

* // The above solution is work for me * // 上面的解决方案对我有用

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

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