在 URL 末尾使用 Android 深度链接
Using Android deeplinking with the end of URL
我想深入 linking 所有 link 看起来像这样 :
https://myapp.com/*/*/quiz.html
我该怎么做?我在我的清单中尝试这个 intent-filter
但 pathPrefix 不起作用:
<intent-filter>
<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="myapp.com"
android:pathPrefix="/.*/.*/quiz\.html"/>
</intent-filter>
在没有 android:pathPrefix
的情况下,它可以正常工作,但它会打开来自 https://myapp.com
的所有 link。
您必须在数据元素中使用 android:pathPattern
。
<data
android:host="myapp.com"
android:pathPattern="/.*/.*/quiz.html"
android:scheme="https" />
然后您可以设置您想要在您的应用中打开的任何 url 模式。阅读 documentation . Also, here 很好地解释了它是如何工作的。
我想深入 linking 所有 link 看起来像这样 :
https://myapp.com/*/*/quiz.html
我该怎么做?我在我的清单中尝试这个 intent-filter
但 pathPrefix 不起作用:
<intent-filter>
<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="myapp.com"
android:pathPrefix="/.*/.*/quiz\.html"/>
</intent-filter>
在没有 android:pathPrefix
的情况下,它可以正常工作,但它会打开来自 https://myapp.com
的所有 link。
您必须在数据元素中使用 android:pathPattern
。
<data
android:host="myapp.com"
android:pathPattern="/.*/.*/quiz.html"
android:scheme="https" />
然后您可以设置您想要在您的应用中打开的任何 url 模式。阅读 documentation . Also, here 很好地解释了它是如何工作的。