Multiple subdomain support with App Links

I've been reading the docs for supporting app links for android and the website my app supports works with subdomains but there's too many subdomains and they are built dynamically. I was wondering if there is a way to support many subdomains without having to specifiy them all in the intent-filter tag.

Here is the link to the example from google: http://developer.android.com/training/app-links/index.html#request-verify The example is in the Supporting app linking for multiple subdomains location.

I thought a regex would work but apparently that's not supported when defining the host. I don't want to list all of them since that would mean having to push a new release with every new subdomain created

<activity ...>
    <intent-filter>
        <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.org" />
        <data android:pathPattern="/.*" />
    </intent-filter>
</activity>

I would prefer not to use a third party lib or service.. But any suggestions that work for you would be appreciated to understand how to make this work.

Answers


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.


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

After multiple test, multiple subdomains supported since android 7.1 (api level 25). On previous version during app installation we got this error : E/HostsVerifier: Invalid host to verify (*.example.org):Input host is not valid.


Need Your Help

Getting value of all the fields from grdiview control in asp.net using jquery?

jquery asp.net gridview

i am using jquery for posting selected data of gridview on to the server for insert using jquery but i am getting only one column(i.e. id) but i want all the fields value of selected row. so for that

Find all Products by Tag in Rails with ActiveRecord

sql ruby-on-rails spree has-many

This is probably something very simple but I'm looking for the optimal way of retrieving all Products by Tag, so to speak. This is with Spree, so I should stick to the way they have modeled their ...