我有一个网站在几种语言,每个链接到一个域名(.com,.co.uk,.de等),我做了一个环球航空与Bubblewrap为它。
我已经将.com设置为TWA的主机名,并且我已经按照官方文档中的指示授权了其他域。(https://developers.google.com/web/android/trusted-web-activity/multi-origin)。
它工作得很好,我可以在环球网中毫无问题地切换域名(使用语言切换器),如果我点击谷歌搜索结果中的.com链接,或者在电子邮件中,它就会在环球网中很好地打开。
但是,如果我点击一个.co.uk链接,它就会在web浏览器中打开,而我希望它也能在环球航空中打开。
是否有可能允许多个主“主机名”,或者允许多个域被识别并在TWA中自动打开?
发布于 2021-01-22 22:38:26
是的,您需要将额外的域添加到AndroidManifest.xml
中的intent-filter
。
使用twa-multi-domain示例,应用程序中的主域是www.google.com
,github.com
和www.wikipedia.com
是附加域。在添加了两个额外的域之后,关于AndroidManifest.xml
的部分应该是这样的(第13到16行是新的):
...
<activity android:name="com.google.androidbrowserhelper.trusted.LauncherActivity"
android:label="@string/app_name">
...
<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="www.google.com"/>
<data android:scheme="https"
android:host="github.com"/>
<data android:scheme="https"
android:host="www.wikipedia.com"/>
</intent-filter>
</activity>
...
https://stackoverflow.com/questions/65810885
复制相似问题