排除几个Urls进行深层链接 [英] Exclude few Urls from deeplinking

查看:78
本文介绍了排除几个Urls进行深层链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在清单中的intent-filter中使用以下过滤器来成功实现应用程序的深层链接:

I could successfully implement deeplinking of app using following filter in the intent-filter in my Manifest:

   <data  android:host="myhost.com"
    android:pathPrefix="/v"
    android:scheme="http" />

例如.我的网址是:

 http://myhost.com/v/login1.php?id=123&name=abc&type=a
 http://myhost.com/v/login1.php?id=123&name=abc&type=b

我要排除

http://myhost.com/v/login1.php?id=123&name=abc&type=c

现在,我想排除一些具有相同前缀的Urls.有可能还是我需要用android:path显式指定所有url?如果可以,该如何处理查询参数的值?

Now I want to exclude a few Urls which have same prefix. Is it possible or Do I need to explicitly specify all urls with android:path ? If so, how to deal with values of query parameters?

推荐答案

很遗憾,我们无法排除任何特定的网址,因为Android不提供该选项.

Unfortunately we can't exclude any certain url, since Android doesn't provide that option.

最佳做法是为提供尽可能精确的pathPrefix .

仅指定没有任何路径的主机前缀是可以的,只要应用程序执行的所有操作都有意义即可.但是,如果有任何链接在应用程序无法处理时应该执行特定的操作,则应该让Web服务正确处理它.在这种情况下,如果您的Web服务可以完成比应用程序更多的功能,则将所有内容都列入白名单并不是一个好主意.

Specify only host without any pathPrefix is OK, as long as all actions carried out by the application makes sense. But if there is any link which should do something specific while the application could not handle, then it should let the web service handle it properly. In this case, whitelisting everything is not a good idea, if your web service can do more than your application.

有些人喜欢只匹配清单中的主机,然后用代码处理不同的情况.如果以其他"条件处理它确实有意义,那么您永远不会知道会捕获到哪些意外的URL.更好的是,仔细地做,只列出我们确定的pathPrefix.

Some people like matching only host in manifest, then handle different cases in code. You never know what unexpected url could be captured, if it really make senses to handle it by "else" condition. Better, do it carefully, only list the pathPrefix that we are sure about.

大多数情况下,回到您的情况,我相信如果查询参数只是不同,则应用程序能够处理该url.因为它属于同一动作(通过API的路由处理程序),所以结果不同.仅当整个路由不同时,才应通过提供正确的pathPrefix来区别对待.

Back to your case, most of the time, I believe that application is able to handle the url if it's only different in query parameter. Because it belongs to the same action (by API's route handler), just different results. Only when the whole routing is different, you should treat it differently by giving the right pathPrefix.

所以有效的例子可能是:

So the valid example could be:

// To handle:
http://myhost.com/v/login1?id=123&name=abc&type=a
// To exclude:
http://myhost.com/v/login2?id=123&name=abc&type=a

然后在AndroidManifest.xml中

Then in AndroidManifest.xml:

<data android:scheme="http"
      android:host="myhost.com"
      android:pathPrefix="/v/login1" />

注意: 如果您偶然发现 noindex.xml (用于应用索引),不是用于深层链接排除.

Note: In case you stumble upon noindex.xml, that is for App Indexing, not for deep linking exclusion.

这篇关于排除几个Urls进行深层链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆