Multiple subdomain support with App Links

Quoting from: Verify Android App Links

Alternatively, if you declare your hostname with a wildcard (such as *.example.com), you must publish your assetlinks.json file at the root hostname (example.com). For example, an app with the following intent filter will pass verification for any sub-name of example.com (such as foo.example.com) as long as the assetlinks.json file is published at https:/ /example.com/.well- known/assetlinks.json:

<application>
  <activity android:name=”MainActivity”>
    <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="*.example.com" />
    </intent-filter>
  </activity>
</application>

It seems the previous answers are outdated and Android now does has a support for wildcard in host name. As per the documentation it is now supported.


You can add your domain as *.example.com. At the docs it's said that the wildcard can be used as the first character of the host. So you could change the manifest to something like this:

<intent-filter . . . >
    <data android:scheme="https" />
    <data android:host="*.example.org" />
    . . .
</intent-filter>

And this should work with the subdomains:

  • example.org
  • www.example.org
  • anyOtherSubDomain.example.org

the website my app supports works with subdomains but there's too many subdomains and they are built dynamically

You are welcome to implement app links for some subset of those (e.g., the ones that are known at the time you build the app). You might even consider cooking up a Gradle plugin that can generate the appropriate manifest elements from a list of domains somewhere.

However, the domains are checked at install time, and there is no means to add new domains except by shipping a new edition of the app with a new manifest.

I was wondering if there is a way to support many subdomains without having to specifiy them all in the intent-filter tag.

No, sorry. Android checks the domains and retrieves the JSON file at install time.

I thought a regex would work but apparently that's not supported when defining the host

You cannot download JSON from a regex.

I don't want to list all of them since that would mean having to push a new release with every new subdomain created

Then either support some common subset, or do not support app links for now. It is conceivable, if somewhat unlikely IMHO, that Google will offer more flexible options for this in the future.

UPDATE: 2019-11-08: It appears that wildcards are supported as of Android 7.1.