Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
775 views
in Technique[技术] by (71.8m points)

android - Exclude few Urls from deeplinking

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" />

Eg. My Urls are:

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

I want to exclude

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

The best practice is to give as precise pathPrefix as possible.

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.

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.

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

Then in AndroidManifest.xml:

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...