Pragnesh
Pragnesh

Reputation: 447

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

Linking.getInitialURL() is return null

Upvotes: 4

Views: 3006

Answers (1)

Kiran Jadhav
Kiran Jadhav

Reputation: 3317

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

Upvotes: 4

Related Questions