0

Say, on my iPhone I would like to open our web page, if I dont have the app installed. Yes, I know about Universal Links by Apple, but this only works for iOS devices and they have to run iOS 9.

And just to be sure, this can be done. I've seen it on Ebay. If you have a link it will open in the app, if installed, or in a browser regardless of device and version:

http://rover.ebay.com/rover/0/e11011.m43.l1123/7?euid=b4a2e0009e73485c9f8b740ae229dba1&bu=43989098353&loc=http%3A%2F%2Fwww.ebay.com%2Fulk%2Fitm%2F162076993293&sojTags=bu=bu
t0mm13b
  • 34,087
  • 8
  • 78
  • 110
Nam
  • 1,856
  • 2
  • 13
  • 18

1 Answers1

3

To be honest, this is kind of a pain to implement on your own. There is no easy way to handle everything without a ton of nasty edge cases, most notably the 'Cannot Open Page" error users will see if they don't have your app installed. Until iOS 9, a reasonable basic implementation was putting a JavaScript redirect like this into a dedicated redirect page on your site:

setTimeout(function() {
  window.location = "https://yourdomain.com";
}, 25);

// If "yourapp://" is registered, the user will see a dialog
// asking if they want to open your app. If they agree, your
// app will launch immediately and the timer won't fire.
// If not installed, you'll get an ugly "Cannot Open Page" 
// dialogue and your fallback page will open when the timer expires.

window.location = "yourapp://";

Unfortunately this would still show a 'Cannot Open Page' error, but until recently it was possible to get around this in a reasonably user-friendly way by using a more nuanced version of this script. Sadly, Apple intentionally broke that with the iOS 9.2 update, so custom URL schemes are actually pretty much useless for deep linking now, unless you are certain the app is already installed on that device. Apple is obviously trying to push Universal Links adoption as much as possible.

The best solution is a combination of custom URL scheme links (with intelligent JavaScript redirections) and Apple's new Universal Links. Universal Links let you use a normal http:// URL to a page on your website (the page could be a simple redirection to your desired fallback webpage without the custom URL trigger that causes the 'Cannot Open Page' error), which is intercepted by your phone and sent directly into your app if installed. Unfortunately (as you noted) Universal Links only work in iOS 9+ and don't work yet when opened inside a lot of apps, so a lot of edge case handling is needed to get a solid experience for every user.

This is quite a lot to handle, so the best option might be a free service like Branch.io (full disclosure: I work with the team) to take care of all the technical aspects. You can find examples of apps using the Branch service (including several from eBay) here.

Alex Bauer
  • 13,147
  • 1
  • 27
  • 44
  • Thanks @AlexBauer. Branch.io seem like a cool solution, but it doesnt seem to handle iOS 9? It asks if it should open the app store even though the app is installed. If you could integrate the iOS 9 detection and use Universal links, Branch.io would be far the easiest solution – Nam May 24 '16 at 07:59
  • @Nam: great point! Actually, we do exactly this once everything is configured. Branch is fully compatible with iOS 9 (and about 6000 other edge cases that we are tracking). Apple often makes major changes without warning, and iOS 9.2 screwed up URL scheme deep links (read more [here](https://blog.branch.io/ios-9.2-redirection-update-uri-scheme-and-universal-links)). They're basically useless now, so what you're experiencing is a known issue and definitely not ideal. Good news is as soon as you get Universal Links enabled, everything will work as expected! – Alex Bauer May 24 '16 at 15:29