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

帅比萌擦擦* 提交于 2021-01-20 12:10:07

问题


  • 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


回答1:


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



来源:https://stackoverflow.com/questions/62693760/react-native-deep-linking-is-not-working-when-app-is-not-in-background-androi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!