Deep linking not working in chrome

2020-01-29 09:20发布

问题:

I am trying to do deep linking such that when someone opens a link from mobile browser, it either opens the app, if it is installed or opens the play store link to download the app.

Here is my URI :

intent://scan/#Intent;scheme=com.example.android;package=com.example.android;end

When I type this in Mozilla Firefox app on Android, it opens my app if it is installed or opens the play store link if it not installed. But, when I type the same thing in Chrome, instead of opening app or play store, it just does a google search. What is wrong with my solution and how do I make it work?

回答1:

This is a known wontfix bug in Chrome 40+ (see the Chromium project ticket here for the full story).

Essentially, the Chrome team feels that if a user actually types something into the address bar, no redirect should ever happen. As you've discovered, this is counter to behavior in all other browsers.

Fortunately it's unlikely a user would actually type an intent:// URI by hand. If you wrap the URL inside a link on a webpage, or offer a link to another page and then issue a redirect of some kind (so that you can detect the user agent and not show a 'broken' intent:// link to users on other browsers), it should work correctly.

If you don't want to handle all these edge cases, you could also try a free service like Branch.io (full disclosure: I'm on the team).