我正在尝试为单个 TWA 应用程序添加子域。我已经完成了从网站到应用程序的资产链接。即使链接完成,我每次都能看到 URL 栏。
字符串.xml
<resources>
<string name="app_name">XXXX </string>
<string name="asset_statements" translatable="false">
[{
\"relation\": [\"delegate_permission/common.handle_all_urls\"],
\"target\": {
\"namespace\": \"web\",
\"site\": \"https://www.xxxx.com\"}
},{
\"relation\": [\"delegate_permission/common.handle_all_urls\"],
\"target\": {
\"namespace\": \"web\",
\"site\": \"https://www.abcd.xxxx.com\"}
}]
</string>
</resources>
AndroidManifest
<activity
android:name="android.support.customtabs.trusted.LauncherActivity">
<!-- Edit android:value to change the url opened by the TWA -->
<meta-data
android:name="android.support.customtabs.trusted.DEFAULT_URL"
android:value="https://www.xxxx.com" />
<meta-data
android:name="android.support.customtabs.trusted"
android:value="https://www.abcd.xxxx.com" />
//在android清单中添加意图过滤器
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<!-- Edit android:host to handle links to the target URL-->
<data
android:scheme="https"
android:host="www.xxxx.com"/>
<data
android:scheme="https"
android:host="www.abcd.xxxx.com"/>
我可以看到没有网址栏的 www.xxxx.com,但对于 www.abcd.xxxx.com,我可以看到网址栏。
https://developers.google.com/digital-asset-links/tools/generator
我使用以下链接检查了链接,它返回该主机已授予应用程序深度链接