Questions › Need a link to url schema to open app store if app is not installled

I have a custom link targeting a custom url schema like

<a href="myapp://"

This link opens a native iOS app if installed. On Chrome, if the app is not installed the link forwards towards the app store which is the required behavior. Problems arise when using Safari. On Safari the link just shows an alert containing an error that says safari cannot open the page because the address is invalid app protocol.

I would like this link to open the native app if it is installed on the device (which is happening correctly), otherwise, if the app is not installed on the device I would like the App Store to be opened instead such that the user may install the app.

Browsing StackOverflow I have found 2 answers to this problem. One is using an onclick handler on the link with a small delay which leads to the App Store. Unfortunately using iOS9 and the latest Safari, this isn't working. Another solution I have found is using the onclick handler to display an <iframe> with display: none which redirect the user to the App Store. This second method is working as expected but is quite inconsistent, it sometimes takes 6-7 seconds for the user to be redirected resulting in horrible UX.

I would like a clean method that works flawlessly every time. Thank you.

0 Answers :