iOS Tip: Redirecting to the app, if it’s installed

A little piece of code, that might come in handy one day. It’s meant for iOS visitors, that want to install your app and it automatically opens the app if it’s installed, or go to the App Store if it’s not.

      function timeoutRedirect() {
        var a = +new Date();
        setTimeout(function() {
          if ((+new Date()) - a < 2000) {
            window.location = "itms-apps://";
        }, 100);
        window.location = "myappscheme:/";
  <body onload="timeoutRedirect()"></body>

So if the redirect can’t be done, you remain on the page and you’re sent to the App Store. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.