I have a website available in several languages, each linked to a domain (.com, .co.uk, .de etc), and I’m doing a TWA with Bubblewrap for it.
I have set the .com as the main hostname of the TWA, and I have authorized the other domains as indicated in the official documentation. (https://developers.google.com/web/android/trusted-web-activity/multi-origin).
It works well, I can switch domains in the TWA without any problem (with a language switcher), and if I click on a .com link in google search results for example, or in an email, then it opens well in the TWA.
However, if I click on a .co.uk link, then it opens in the web browser, whereas I would like it to open in the TWA as well.
Is it possible to allow more than one main "hostname", or to allow multiple domains to be recognized and opened automatically in the TWA?
Yes, you will need to add the extra domains to the
intent-filter
inAndroidManifest.xml
.Using the twa-multi-domain sample, the main domain in the app is
www.google.com
andgithub.com
andwww.wikipedia.com
are extra domains. After adding the 2 extra domains, this is how the section onAndroidManifest.xml
should look like (lines 13 to 16 are new):