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

1

4
  • 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

Rwanda answered 2/7, 2020 at 10:0 Comment(2)
you got any solution for this ? I am getting the same issue ?Giffard
@PankajNegi try below solution is works.Rwanda
M
4

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

Mahayana answered 2/7, 2020 at 10:1 Comment(1)
this one was super helpful, thanks for posting!Ictinus

© 2022 - 2024 — McMap. All rights reserved.