flutterandroid-12android-deep-linkflutter-deep-link

Flutter / Android 12 - Using deep links with a custom scheme makes the https scheme disabled by default


I'm currently working on deep links on Flutter. I managed to have almost everything working, except for this strange behaviour on Android 12 only. (iOS working also fine).

If I set a custom scheme for the deep links in the manifest, then Android 12 will make the https links to not open the app, but I can see the domain is actually just disabled if I go in "Applications -> Default Applications -> Link opening -> My App -> Web links", and enabling it solves the issue. If I don't set a custom scheme, then the domain is enabled on build.

It's currently only been tested on local debug builds if this matters.

As I said, beside this on Android 12, everything works as intended. I put this configuration :

<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:host="my.domain.fr" />
   <data android:scheme="https" />
   <data android:scheme="http" />
   <data android:scheme="custom" /> <------ Removing this makes a difference
</intent-filter>

I've set the assetlinks with the correct domain :

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "my.app.bundle",
    "sha256_cert_fingerprints": ["AV:ER:YN:IC:ES:HA:25:6X"]
  }
}]

From what I've understood, the links being enabled when not using the custom scheme are a good clue it works as intended, and the file is also said to be working fine with online testing tools.

The similar working method on iOS works without any issue.

I'm expecting the web links https://my.domain.fr to open in the app, but the option to do so is disabled in the app settings by default ONLY IF I use a custom scheme alongside.


Solution

  • you have to separate the intent-filter for the custom scheme.

    from this

    <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:host="my.domain.fr" />
           <data android:scheme="https" />
           <data android:scheme="http" />
           <data android:scheme="custom" /> <------ Removing this makes a difference
        </intent-filter>
    

    to this

    <intent-filter android:autoVerify="true" android:label="testHttpDeepLink">
           <action android:name="android.intent.action.VIEW" />
           <category android:name="android.intent.category.DEFAULT" />
           <category android:name="android.intent.category.BROWSABLE" />
           <data android:host="my.domain.fr" />
           <data android:scheme="https" />
           <data android:scheme="http" />
    </intent-filter>
    <intent-filter android:autoVerify="true" android:label="testAppDeepLink">
           <action android:name="android.intent.action.VIEW" />
           <category android:name="android.intent.category.DEFAULT" />
           <category android:name="android.intent.category.BROWSABLE" />
           <data android:scheme="custom" />
    </intent-filter>