我正在尝试将渐进式Web应用程序添加到我的服务器。我不想为每个应用程序创建一个新的网站。我的偏好是将每个应用程序添加到以下网站的子域中:www.example.com/app1
问题在于,当我在此处运行语句列表生成器时:https://developers.google.com/digital-asset-links/tools/generator
仅当我将assetlinks.json放在此处:www.example.com时,此方法才有效。如果是这种情况,那么我只能在www.example.com中拥有一个应用程序。我已经尝试在此处放置assetlinks.json 1)www.example.com/app1 2)www.example.com/app1/.well-known和3)www.example.com。唯一有效的方法是#3。
还向androidmanifest.xml添加了以下意图过滤器,但该过滤器不起作用:
<intent-filter android:label="@string/app_name" android:autoVerify="true" >
<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="example.com"
android:pathPrefix="/app1" />
</intent-filter>
我不敢相信每个渐进式Web应用程序都必须有一个不同的网站。有什么建议吗?
答案 0 :(得分:1)
可以做到。例如,假设您正在开发2个应用程序:
而且,由于这些应用程序将是不同的TWA,所以这也意味着每个应用程序都有不同的程序包名称:
assetlinks.json文件应该在https://example.com/.well-known/assetlinks.json上可用,并且应该列出两个应用程序:
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "com.example.app1",
"sha256_cert_fingerprints": ["<APP_1_FINGERPRINT>"] }
},
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "com.example.app2",
"sha256_cert_fingerprints": ["<APP_2_FINGERPRINT>"] }
}
]
每个应用程序都有其自己的asset_statements声明,将其链接到授权来源:
[{ "relation": ["delegate_permission/common.handle_all_urls"],
"target": {"namespace": "web", "site": "https://example.com"}}]
需要注意的几件事:
如果上述两个问题中的任何一个都是问题,那么使用子域将是一个更好的解决方案。