skip to Main Content

I’m trying App Links to launch a Flutter-made Android app from a URL.
I tried the following, but the app doesn’t open, just the web page. I tried entering the URL directly in the search field, and jumping from the button with the tag, but the result was the same.

AndroidManifest.xml (Change <example.com> to my custom domain)

            <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
            <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:host="<example.com>" />
            </intent-filter>

            <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
            <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" />
                <data android:host="<example.com>" />
            </intent-filter>

Get SHA256

$ ./gradlew signingReport

Result:

Variant: debug
Config: debug
Store: 
Alias: AndroidDebugKey
MD5: 
SHA1: 
SHA-256: <debug key>
Valid until: 
----------
Variant: release
Config: release
Store: 
Alias: key
MD5: 
SHA1: 
SHA-256: <release key>
Valid until: 
----------

assetlinks.json in /.well-known (Change <My SHA256> )

[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.app1",
      "sha256_cert_fingerprints":
        ["<debug key>", "<release key>"]
    }
  }
]

Environment

MainActivity.kt

package com.example.app1

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()

2

Answers


  1. 1.make sure that you declare both the debug and release sha256 keys in the assetlinks.json file.That is an important thing to do because the app can work in either debug or in release mode,while both keys will need to be recognized

    [
      {
        "relation": ["delegate_permission/common.handle_all_urls"],
        "target": {
          "namespace": "android_app",
          "package_name": "com.example.app1",
          "sha256_cert_fingerprints": [
            "<debug key>",
            "<release key>"
          ]
        }
      }
    ]
    

    2.instead of combining http and https in the same intent filter,they should be separated.

    <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:host="example.com" />
    </intent-filter>
    
    <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" />
        <data android:host="example.com" />
    </intent-filter>
    

    after these changes,try to launch the app again from the url

    Login or Signup to reply.
  2. if you are using app links no need to put this line here

    " meta-data android:name="flutter_deeplinking_enabled" android:value="true" "

    (only put if you are using Go router or navigator 2.0 which handles the links automatically).

    After installing the app, check in the app info if the url is registered under open by default section.

    Just for the confirmation – does you assetlinks.json follows this path : web/.well-known/assetlinks.json

    If you need you can check out this repo which is a simple example using go router for handling links: https://github.com/sauravnavneet/demo_testapp

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search