Android深层链接忽略了某些网址 [英] Android Deep linking omit certain url
问题描述
我已经成功实现了到我的应用程序的深层链接,但是我遇到了问题.
<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:host="*.example.com"
android:scheme="https"/>
</intent-filter>
此意图过滤器可处理所有链接,但我不想捕获某个网址,即
https://www.example.com/hello/redirect/
到目前为止我尝试过的事情:
我尝试输入要手动捕获的所有URL
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/m/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/c/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/p/">
...
但是我的主页URL https://www.example.com
不起作用.
如果我使用
android:pathPrefix="/"
然后,它将开始再次捕获所有URL,包括我要忽略的URL.
我也尝试过使用android:pathPattern
,但是它无法理解像^((?!redirect).)*$
这样的复杂正则表达式,当我在字符串和所有形式中尝试时,都可以正常工作.
任何人都知道我该如何省略某些URL?
更新:
如@PLNech所建议,此处,我添加了所有需要使用android:pathPrefix
捕获的URL,并使用android:path: "/"
捕获我主页的URL,即 https://www.example.com/ >
<data
android:host="*.example.com"
android:scheme="https"
android:path="/"/>
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/m/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/c/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/p/">
Android深度链接机制没有提供显式排除某些URL的方法:您可以 要么显式地包含android:path
的路径,要么包含与android:pathPrefix
的前缀匹配的路径,或者与android:pathPattern
的通配符匹配的路径,您可以在其中使用*
或.*
./p>
对于您而言,您将必须使用"/"
并具有每个指向随应用程序打开的网站(包括您的首页)的链接,或者使每个深层链接共享一个公共前缀.
您还可以查看airbnb的 DeepLinkDispatch 库,该库似乎 This intent filter handles all the links but I don't want to catch a certain url i.e. What I tried so far: I tried entering all the URLs that I want to catch manually But then my home page URL If i use then this will start catching all the URLs again including the url i want to omit. I also tried using Anybody know how can I omit certain URLs? UPDATE: As suggested by @PLNech here, I added all the URLs that I need to catch using
The Android deep linking mechanism does not provide a way to explicitly exclude some URLs: you can either include explicitly paths with In your case, you will have to either use You can also have a look at airbnb's DeepLinkDispatch library, which seems to allow excluding specific URLs. 这篇关于Android深层链接忽略了某些网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!https://www.example.com/hello/redirect/
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/m/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/c/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/p/">
...
https://www.example.com
doesn't work.android:pathPrefix="/"
android:pathPattern
, but it can't understand a complicated regex like this ^((?!redirect).)*$
which works fine when I try it in strings and all.android:pathPrefix
and use android:path: "/"
to catch the URL of my home page i.e. https://www.example.com/ <data
android:host="*.example.com"
android:scheme="https"
android:path="/"/>
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/m/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/c/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/p/">
android:path
, include paths matching a prefix with android:pathPrefix
or matching a wildcard with android:pathPattern
where you can use *
or .*
."/"
and have every link to your website opened with your app (including your homepage), or have every deep link share a common prefix.