Projects with Native Code Only
The following section only applies to projects with native code exposed.Linking gives you a general interface to interact with both incoming and outgoing app links.
Custom URL scheme isn’t the only way to open your application on mobile. You don’t want to use a custom URL scheme in links in the email because then the links would be broken on desktop. Instead, you want to use a regular https links such as https://www.myapp.io/records/1234546. Android calls it Deep Links (Universal Links - iOS).
Built-in URL Schemes
As mentioned in the introduction, there are some URL schemes for core functionality that exist on every platform. The following is a non-exhaustive list, but covers the most commonly used schemes.Enabling Deep Links
To enable a component to receive messages from another app and map the message target URI, set thelaunch-uris in the manifest.toml file.
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 URL -
If 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.
Parameters:
getInitialURL()
null.
getInitialURL() can return null when debugging is enabled. Disable the debugger to ensure it gets passed.
openSettings()
openURL()
url with any of the installed apps.
The method returns a Promise object. If the user confirms the open dialog or the url automatically opens, the promise is resolved. If the user cancels the open dialog or there are no registered applications for the url, the promise is rejected.
Parameters:
This method will fail if the system doesn’t know how to open the specified URL. If you’re passing in a non-http(s) URL, it’s best to check canOpenURL() first.

