Android 允许使用特定模式进行深层链接
Android allow deeplinking with certain patterns
我对如何在 Android 上实施深层链接感到困惑,因为他们决定不让我们 omit/exclude 特定的 urls。
假设我有以下 urls
https://www.example.com/detail/:id
https://www.example.com/detail/:id/manage
我想阻止 Android 在第二个 url 上打开应用程序,但在第一个上允许它。这怎么可能?
不幸的是你不能,如果你拦截第一个url第二个也会被拦截。 Android没有提供排除url的具体方法 https://developer.android.com/training/app-links/deep-linking
如果您是 url 所属网站的所有者,这是可能的。 Verify Android App Links 是一种特殊类型的深层 link,它允许您的网站 URL 立即打开您的 Android 应用程序中的相应内容(无需用户 select 应用程序)。
步骤 1:创建 assetlinks.json 文件
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example",
"sha256_cert_fingerprints":
["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
}
}]
第 2 步:将 assetlinks.json 上传到您域的根目录下名为 .well-known
的文件夹下
https://domain.name/.well-known/assetlinks.json
第 3 步:更新您的 AndroidManifest.xml
以将 Intent 过滤器注册到特定路径。设置 android:autoVerify="true"
<activity android:name=”MainActivity”>
<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:path="/path"
android:host="example.com" />
</intent-filter>
</activity>
这将确保只解析 AndroidManifest.xml
中指定的路径。
我对如何在 Android 上实施深层链接感到困惑,因为他们决定不让我们 omit/exclude 特定的 urls。
假设我有以下 urls
https://www.example.com/detail/:id
https://www.example.com/detail/:id/manage
我想阻止 Android 在第二个 url 上打开应用程序,但在第一个上允许它。这怎么可能?
不幸的是你不能,如果你拦截第一个url第二个也会被拦截。 Android没有提供排除url的具体方法 https://developer.android.com/training/app-links/deep-linking
如果您是 url 所属网站的所有者,这是可能的。 Verify Android App Links 是一种特殊类型的深层 link,它允许您的网站 URL 立即打开您的 Android 应用程序中的相应内容(无需用户 select 应用程序)。
步骤 1:创建 assetlinks.json 文件
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example",
"sha256_cert_fingerprints":
["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
}
}]
第 2 步:将 assetlinks.json 上传到您域的根目录下名为 .well-known
https://domain.name/.well-known/assetlinks.json
第 3 步:更新您的 AndroidManifest.xml
以将 Intent 过滤器注册到特定路径。设置 android:autoVerify="true"
<activity android:name=”MainActivity”>
<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:path="/path"
android:host="example.com" />
</intent-filter>
</activity>
这将确保只解析 AndroidManifest.xml
中指定的路径。