How to open ios app using url?

Vivek Sinha picture Vivek Sinha · Mar 8, 2016 · Viewed 32.9k times · Source

I want to open my ios app using URL schemes. I am able to open app using this. But I want if app is not installed then app store should be opened where user can download app. Is this possible? How can I do that?

EDIT Explaining question step wise:

  1. I have a mail in my inbox with a url.
  2. I click on URL then i. If app is installed in phone, app will launch. ii. Otherwise app store will be opened to download app.

Thank

Answer

Vivek Sinha picture Vivek Sinha · Jul 14, 2017

I handled it via my server side code:

if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("com.myapp://");
setTimeout(function() {
                if (!document.webkitHidden) {
                    location.replace("https://itunes.apple.com/app/xxxxxxxx");
                }
            }, 25);}
else if ((navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/Android/i))) {
location.replace("https://play.google.com/store/apps/details?id=packagename&hl=en");}
else  {
location.replace("http://www.example.com");}

I put this in my www.mysite.com/download page & share this url via campaigns.