How to do appLinking/ deeplinking in flutter app, Including intent filter and domain/url verification?

Need help with step by step implementation of app-linking/ deep-linking in flutter, for android

The following answer would help anyone who is looking for enabling app linking in flutter app.(The answer does not include information about handling the url after opening the app,it just provide info to setup applinking and assetlink.json file)

App-Linking in flutter can be divided into 2 steps –

  1. Intent-filter & Handling in app.
  2. Verifying the domain name/ URL.

For Intent Filter –

Inside AndroidManifest file, present at – app>src>main, inside activity with other intent filters, you need to add intent filter to handle the urls :

            <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" />


            <data android:scheme="http" />
            <data android:scheme="https" />

            <data android:host="domainname1.com" />
            <data android:host="domainname2.com" />

        </intent-filter>

in place of domainname1.com and domainname2.com you can add your domain name that you want to handle inside app, here your work to open the app on clicking of url is done.

To verify the domain name –
You need to add a assetlinks.json file containing the sha256 key and the package name, this file confirms that the app is related to this specific domain.

For this step you can go to assetlinks.json verification. Here you can specify the domain name, app package name, sha256 key of the app. Then click on generate statement and it will provide the path where you have to host the file, the file name and url should be exectly as specified.

Here you need to take care of two things –

  1. That the package name and sha256 key is correct, sha256 can be multiple for single app , like debug mode and release mode have different keys, and app linking will only work for specific app if its correct keys are present , if you want to add multiple keys you can do as follow :
[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "<package_name_here>",
      "sha256_cert_fingerprints": ["B8:..<complete sha256 key>..:38"]
    }
  },
  {
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "<package_name_here>",
    "sha256_cert_fingerprints": ["A5:..<other complete sha256 key>..:38"]
  }
}
]
  1. After uploading in 2-3 min you can test using test statement button, if it is still showing error then make sure that the file uploaded is in correct path, (you can just check by gowing on that url), and make sure that file format while hosting is json, you can check if hosted file is in json or not by just checking the content type in header.

You can also use this command to check if the app url is verifed or not

adb shell pm get-app-links <your_package_name>

If the url is written as verified, only then is everything perfectly working.

Note: These steps will only setup to open a specific URLs in your app, but still you need to do routing or use gorouter to handle what happens inside the app when app is opened using specific URLs. If any help is needed regarding that, you can add in comment

Leave a Comment