Flutter Deep links: iOS (Universal links) and Android (App links)

iOS (Universal links)

First you need to enable the runner domains. This can be done either through XCode or through the Runner.entitlemens file.
Through XCode:
Go to Project → Runner → Targets and in the Signing & Capabilities tab, click + Capability. In the drop-down list select Associated Domains. In the domains field, type applinks:[OUR_HOST] and we get applinks:myapp.com. Through the Runner file: Go to ios/Runner/ Runner.entitlemens and add the following code:

<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:[НАШ_ХОСТ]</string> // applinks:myapp.com

</array>

Next, you need to create and upload an apple-app-site-association file to our host. The file has a JSON structure, but has no extension. It looks like this:

{
"applinks": {
"apps": [],
"details": [{
"appID": "[TEAM_ID].[APP_BUNDLE_ID]",
"paths": ["[PATH_FOR_REDIRECTION]"]
}]
}
}

To get TEAM_ID you need to go to the developer account in the Account section → Membership and find the Team ID field (for example: UP******H, where * are numbers 0–9 or letters A-Z). APP_BUNDLE_ID — the id of your project (for example: com.example.myapp). PATH_FOR_REDIRECTION indicates which page of the site we will be offered to go to in the application. Let’s take a closer look:

"paths": [
"/your_path", // бwill be redirected if we go to <https://myapp.com/your_path>
"/your_path/*", // will be redirected if we go to <https://myapp.com/your_path/[что_угодно_дальше]>
"*", // will be redirected to any link <https://myapp.com/[anything_further]>
"NOT /your_path", // will be redirected to any link other than <https://myapp.com/your_path>
"NOT /your_path/*", // will be redirected to any link other than <https://myapp.com/your_path/[anything_further]>
]

The apple-apple-site-association file must be either in the root folder of your host or in the .well-known/apple-apple-site-association directory.

Notes:
You can check if all is well with the apple-apple-site-association file here or here.
The schema must be “https”.
You can read more about Universal links for iOS here.

Android (App links)

First, open the android/app/src/main/AndroidManifest.xml file and specify:

<manifest ...>
<!-- ... other tags -->
<application ...>
<activity ...>
<!-- ... other tags -->
<!-- App Links -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with https://YOUR_HOST -->
<data
android:scheme="https"
android:host="myapp.com" />
</intent-filter>
</activity>
</application>
</manifest>

Where android:host is your host. In the example it is myapp.com.
After android:host you can also specify android:pathPrefix = “/[YOUR_PATH]” — the path where your application will open, for example:

<data
android:scheme="https"
android:host="myapp.com"
android:pathPrefix = "/articles" />

Also in the root folder, or in the .well-known you need to add a file assetlinks.json:

{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "[APP_BUNDLE_ID]", // example: com.example.myapp
"sha256_cert_fingerprints": [
"[YOUR_MACHINE_256_FINGERPRINT_1", // for example debug key
"[YOUR_MACHINE_256_FINGERPRINT_2", // for example release key
"[PLAY_MARKET_256_FINGERPRINT", // If you use automatic keys in the play store
]
}
}
]

In sha256_cert_fingerprints, you need to add the keys of those devices from which the application will be collected.
These can be found either through Android Studio or through the command line.
More information on App links can be found here.
Thank you for your time, I hope I was helpful. See you in the next article❤️.

We are a team of rock-star developers, which provides fully-flexible and powerful products 💥.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store