Search code examples
androidreact-nativeurlnavigationdeep-linking

React-native Linking.openUrl doesn't open link to another screen


I have a react-native app and I'm trying to "redirect" user to another screen(based on url received from a deep linking", for example, if an user is on Screen A, then exits the app, clicks on the link, Screen A opens up and from Screen A the user should be redirected to the screen B. I'm getting the deep link on the screen A but can't redirect user to Screen B on android. My code:

Linking.openURL(deepLink)

The deeplink has this structure:

myApp://mainPage/address

When I use Linking.canOpenURL => it throws an error. I can't seem to figure out what I'm doing wrong, any suggestion is appreciated.thank you


Solution

  • Solved: posting here in case anyone else runs into the same issue - I changed Linking.openURL(deepLink) to branch.openURL(deepLink) and it worked