【问题标题】:React Native - Deep linking is not working when app is not in background (Android, iOS)React Native - 当应用程序不在后台(Android,iOS)时,深度链接不起作用
【发布时间】:2020-10-22 21:36:24
【问题描述】:
  • 如果应用程序在后台

    将打开特定屏幕。

  • 如果应用程序不在后台或终止应用程序

    它只会显示第一个屏幕。

Linking.getInitialURL() 返回 null

【问题讨论】:

  • 你有什么解决办法吗?我遇到了同样的问题?
  • @PankajNegi 试试下面的解决方案是可行的。

标签: android ios react-native deep-linking


【解决方案1】:

如果您想在应用被终止或尚未启动的情况下进行重定向,请找到以下简单的解决方案:

// 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();
  }, []);

*// 上面的解决方案对我有用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-14
    • 1970-01-01
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 2019-08-18
    • 2020-09-21
    • 1970-01-01
    相关资源
    最近更新 更多