Implementing Universal or Deep Links with Expo in React Native

Tiempo de lectura: 3 minutos

Returns only the HTML translated, without any additions.

Deep links allow us to open sections of our APP using a link or URL.

First we are going to implement deep links in Android. To do this:

We are going to go to app.json and add:

Assuming the URL we want to open is https://myapp.com/main.

To get the content of the opened URL, we add inside our navigation screen or main screen:

Returns only the HTML translated, without any addition.

To manage the opening of links and redirect to the correct screens, we will have to implement LinkingOptions within our NavigationContainer:

In this case I suppose that we have a screen called Home that may receive a code and we want to open it and also pass the code (if we don’t have a code we can remove that part and leave only main/).

This configuration will obtain the filter of the prefix directly and share it with the indicated screens.

Returns only the HTML translated, without any addition.

It is very important that this code be within the NavigationContainer of our APP in order to allow us to use it.

To get it on the next screen, we simply indicate the parameter and we will obtain it:

The link that we are opening is something like:

https://myapp.com/12345

Android

We need to go to Android/app/src/AndroidManifest.xml

And modify the filter with this:

This will open links for us.

If we have problems opening links on Android, it is possible that we need to verify the domain, for this we need to go to our domain, create a folder called .well-known and inside a file called assetlinks.json

We will need to add this file, indicating the SHA256 signature of the certificate or certificates with which the APP has been signed.

If you do not know how to obtain the certificate signature, I indicate it here:

iOS

To configure deep links in our iOS app, we will need to do the following:

Activate associated links.

We are going to the Apple developer console.

Open: Certificates, Identities & Profiles > Identifiers

Apple Certificates Identities and Profiles

Now search for your APP and click on it.

Select associated domains:

Associated Apple Domains

Now you click on save, it will tell you that the provisioning certificate must be renewed.

Now we have to open the app with Xcode:

Signing and capabilities ios

Now we choose + Capability and add Associated Domains

Associated Domains Capability xcode

And we add our URLs in this way:

applinks:myapp.com

And we can indicate www. as well.

applinks:myapp.com

Verify domain for Apple account.

The associated domain must be backed by a file called apple-app-site-association (AASA) that must be hosted on the web server. This file defines the routes and apps that support deep linking.

Create a file apple-app-site-association with the following content:

Replace <TEAM_ID> with your team ID in Apple Developer (you can find it on your developer account). Replace <BUNDLE_ID> with your app’s identifier (for example, com.myapp).

Place the file at domain https://www.myapp.com/.well-known/apple-app-site-association

You can validate the link from here.

Leave a Comment