How to build multi-origin Trusted Web Activity with a wildcard for subdomains

307 views Asked by At

Given a web application with multiple sub-domains. The user is able to navigate from one subdomain to another. The number of subdomains is not fixed (a new subdomain can be created during the user registration). I'm trying to implement TWA with bubblewrap using wildcards in the host name of the intent filter (e.g. *.example.com). For that purpose I've adjusted app\build.gradle file with the line below:

resValue "string", "hostName", "*.example.com"

And also I've created the correct /.well-known/assetlinks.json endpoint for each subdomain and root domain. The SHA256 fingerprint is correct.

It was enought to make it workable on my personal device, and even on android emulator. I could easily switch between subdomains without having url bar. But it's not the case for other people. Other people still see app pages rendered as a Custom Tabs (with URL bar). It seems the solution does not provide deterministic result.

I know there is great article about creating multi-origin TWA, but as for as I understand it's applicable only for the fixed number of (sub)domains.

Could someone, please, help me reaching the right solution?

2

There are 2 answers

0
sammy34 On

Google Bubblewrap project members have confirmed that wildcard subdomains aren't supported for TWAs, see here:

https://github.com/GoogleChromeLabs/bubblewrap/issues/661#issuecomment-1108374595

2
gesin On
<meta-data
    android:name="android.support.customtabs.trusted.ADDITIONAL_TRUSTED_ORIGINS"
    android:resource="@array/additional_trusted_origins" />

https://stackoverflow.com/a/77022195/22482812