Open my app from URL scheme in Android

前端 未结 2 1837
臣服心动
臣服心动 2021-02-09 17:17

I know there are several questions on SO about this, but none of them are helping to resolve my issue.

I want to be able to click a link from an email/text/browser

相关标签:
2条回答
  • 2021-02-09 17:47

    Chrome does not open apps from manually-entered URI schemes. In fact, a manually-entered link will never launch an external app in Chrome. This is by design — for whatever reason, the Chrome team feels users should always be kept inside the browser after entering an address.

    You can work around this to some extent by putting the deep link behind a user-drive action (a standard <a> tag, for example), but the Chrome has its own standard called Chrome Intents that you are supposed to use instead. Depending on the device you are using, this could also be the case for the standard browser.

    In other apps, it's up to the app in question whether a custom URI scheme is identified as a 'clickable link'. For best compatibility, you'll want to wrap it inside a regular http:// link with a redirect.

    If you're interested in an in-depth explanation of the complications around deep linking, this post is a good place to start. If you just want it to work without a lot of extra effort, Branch.io (full disclosure: I'm on the Branch team) solves this problem as a free service.

    0 讨论(0)
  • 2021-02-09 18:11

    There is no requirement for any app to pay any attention to myscheme://open.

    In particular:

    • There is no requirement for any Web browser to try to launch some third-party app when you type myscheme://open into the address bar, because users are unlikely to do that in the real world.

    • There is no requirement for an email program to try to create an ACTION_VIEW Intent for myscheme://open.

    • There is no requirement for an SMS client to search all incoming messages for the string myscheme://open, realize that this is somehow an app link, and do something with it.

    You will have somewhat better luck overall using an https (or, in a pinch, http) URL as your app link (the http://www.example.com/gizmos URL from the documentation that you linked to). Then, SMS clients might recognize that this is a URL and do something with it. And, overall, you should be taken either to your app or to your Web page, both of which are at least somewhat useful to the user. However, your app still will not necessarily open when the user types your URL into the address bar, as browsers may not expect an app link to be entered there.

    You can increase the odds of an https app link working, and working the way that you want, by publishing a digital asset links file and tying that into your manifest.

    However, overall, this is still reliant on clients opting into paying attention to this stuff. Sometimes they will, because Android makes it relatively easy to do so. Sometimes they will not. A Web browser is welcome to see your URL, see that it is https, say "hey, as a Web browser, I know how to handle this!", and go load that Web page, ignoring your installed app. You and I might consider that to be a bug in that browser; the developers of that browser are welcome to disagree.

    I have found that navigating Chrome to market://details?id=com.myapp does not open the play store

    This goes back to the "developers can do what they want" part. If you clicked a link in a Web page to that URL, there is a chance that Chrome will take you to the Play Store. However, Chrome is not obligated to treat the address bar the same as it treats a link in a Web page.

    0 讨论(0)
提交回复
热议问题