I have a react app which is redirecting to a React native App with this code:
<a href="my.app://">go to my app</a>
I want to pass some information to my react native app, so I Need to get the exact address that was called in order to redirect me to the app, how can I accomplish that both in IOS and Android ?
CodePudding user response:
You can use Linking component from RN package https://reactnative.dev/docs/linking#handling-deep-links
Handling Deep Links There are two ways to handle URLs that open your app.
If the app is already open, the app is foregrounded and a Linking 'url' event is fired You can handle these events with
Linking.addEventListener('url', callback)
- it callscallback({ url })
with the linked URLIf the app is not already open, it is opened and the url is passed in as the initialURL You can handle these events with
Linking.getInitialURL()
- it returns a Promise that resolves to the URL, if there is one.