Android Custom Url to Open App Like in iOS

iOS custom URL schemes vs. Universal Links and Android counterpart

URLs with custom schemes don't get displayed as links in many Android applications (SMS, E-Mail, WhatsApp, Hangouts, you name it), which de facto make them unopenable by your application. iOS however does not allow for defining scheme + host + path like android does.

One possible (hacky) solution to this is browser sniffing (I know, evil, but so are non-standard extensions to well-defined behavior, especially if nothing was broken in the first place) at the resource you expose over a URL reachable over HTTP(s).

You could check if the request origins from the iOS-platform you offer native apps for; then you would have to make sure that the device has your application installed (this is getting uglier and uglier; see here for example) and then, only then redirect to yourapp://the-rest-of-your/uri, which causes a prompt shown to the user whether they want to open the address inside the application or not. (Tested on an iPhone 4 with iOS 8, Safari browser.)

Is it possible to open an Native iOS app by using Custom url scheme without a webpage directs to custom url?

The simple answer is likely no, as you have little control over how individual apps will handle links. The complex answer is that you should do something about it. Note that it won't always require returning a full web page -- on Android with Chrome you can fire a 307 redirect straight to a Chrome intent.

You could set up a simple web server that, when pinged, returns `window.location = 'test://'.

Or better yet, you can try to open the URI scheme in an iframe then fallback to a web URL if the app isn't present. This can be achieved using the following mechanisms:

  1. on iOS 9, use Universal Links
  2. in Chrome (and soon, Firefox 41.0!) use Chrome Intents
  3. on all other browsers, use client-side javascript

Here's an example of client-side javascript:

<script type="text/javascript">
window.onload = function() {
// Deep link to your app goes here
document.getElementById("l").src = "my_app://";

setTimeout(function() {
// Link to the App Store should go here -- only fires if deep link fails
window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
}, 500);
};
</script>
<iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>

This is exactly what we do at my company, branch.io. We're constantly dealing with changes to browsers and webviews because there are always new scenarios to cover. It's essential to look at the user agent string when deciding how to deeplink a user into your app.



Related Topics



Leave a reply



Submit