iphone - iOS: opening app with custom URL if installed, itunes otherwise -


i implemented smart app banner website in order redirect user our android or ios app. parsing user agent redirect android app or google play store (using intent filter): i'd same ios, opening app if it's installed , opening itunes elsewhere.

i managed open app, if it's installed, using custom url scheme

<a href="myurlscheme://main"> 

now i'd make itunes start if app not installed on device. how can achieve that?

thank you

to honest, kind of pain implement on own. after you've detected ios user agent, implement javascript redirection on server this:

settimeout(function() {   window.location = "https://itunes.apple.com/path/to/your/app/"; }, 25);  // if "yourapp://" registered, user see dialog // asking if want open app. if agree, app  // launch  , timer won't fire. // if not installed, you'll ugly "cannot open page"  // dialogue , app store launch when timer expires.  window.location = "yourapp://"; 

obviously isn't ideal solution , has ton of nasty edge cases, notably 'cannot open page" error users see before being redirected app store if don't have app installed. until recently, possible around in reasonably user-friendly way using more nuanced version of script. sadly, apple intentionally broke that ios 9.2 update.

you enable universal links. apple knows annoying problem , trying help. universal links let use normal url page on website (which simple redirection app store without custom url trigger causes 'cannot open page' error), intercepted phone , sent directly app if installed. unfortunately universal links work in ios 9+, , don't work yet when opened inside lot of apps.

the best solution combination of above methods: universal links , applinks everywhere supported, , intelligent javascript redirections fallback. quite lot handle, best option might free service branch.io (full disclosure: work team) take care of technical aspects.


Comments