Implementation Universal/AppLink in both iOS and Android

Android

  1. Host a website with https then upload config files: https://your-web-host-name/.well-known/assetlinks.json
[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "<android-app-package-name>",
      "sha256_cert_fingerprints": ["<android-fingerprint>"]
    }
  }
]

get android-debug-fingerprint from

keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

  1. Add code to android/app/src/main/AndroidManifest.xml
<activity ...>
  ...
  <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="https"
        android:host="<host>"
        android:pathPrefix="<website-path-after-host(if any)>" />
    <!-- note that the leading "/" is required for pathPrefix-->
  </intent-filter>
</activity>
  1. Verify website that can be used as universal/app link by entering

https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://<host>&relation=delegate_permission/common.handle_all_urls

  1. Enter path to assetlinks.json file in flutter project by creating file android/app/src/main/res/values/strings.xml
<resources>
  <string name="asset_statements" translatable="false">[{"include": "https://<host>/.well-known/assetlinks.json"}]</string>
</resources>

And add reference to path by android/app/src/main/AndroidManifest.xml

  1. Test by running

adb shell am start -W -a android.intent.action.VIEW -d "https://<host><website-path-after-host(if any)>"

iOS

  1. Host a website with https then upload config files: https://your-web-host-name/.well-known/apple-app-site-association
{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "<team-id>.<ios-app-package-name>",
        "paths": [
          "*"
        ]
      }
    ]
  }
}
  • Get TEAMID from https://developer.apple.com/account/#/membership (you need to have apple developer team)
  • ios-app-package-name is the app name that is registered in https://developer.apple.com/account/resources/identifiers/list. The name must be unique. The identifier with the same package name registered must also be configured with Associated domains enabled.
  • Test by running xcrun simctl openurl booted 'https://<host><website-path-after-host(if any)>'

Refer:

Comments !

Links

Social