Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone browser: Checking if iPhone app is installed from browser

Tags:

browser

iphone

I have web page where I have Button that either opens app (if it installed) or directs to App store if app isn't installed. It all works if App is installed (I call into "MYAPP://"). However, if app is not installed Safari shows error message "Can not open URL" and that's it. Is there way to disable that message from JScript or is there another way to find out from JScript if app installed (instead of hitting app URL)?

To MODERATOR: I saw someone asked similar question and Moderator wrongly marked it as duplicate. Please understand that question was specifically about doing it from Browser.

Found somewhat suitable solution here

BTW if someone interested in how to do same thing for Android, here is code. We are using Dojo library:

  dojo.io.iframe.send({
    url: "yourApp://foo/bar",
    load: function(resp) {
      // nothing to do since it will automagically open App
    },
    error: function () {
      window.location = "go to Android market";
    }
  });
like image 547
Andrei V Avatar asked Sep 27 '11 17:09

Andrei V


People also ask

Can a website check if an app is installed?

Your website can check if your Android app is installed.

How do I know if app installed on my iPhone?

In App store, click on the user icon top right of screen. Select "Purchased", then ensure that "All" is selected. Scroll down that list - Apps will either have an "Open" button (if they are installed), or a cloud download icon if they are int installed but eligible to be installed on that device.

Can you install apps from browser on iOS?

Yes, safari will detect the *. ipa and will try to install it, but the ipa needs to be correctly sign and only allowed devices would be able to install it.


2 Answers

At Branch we use a form of the code below--note that the iframe works on more browsers. Simply substitute in your app's URI and your App Store link. By the way, using the iframe silences the error if they don't have the app installed. It's great!

<!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript">
            window.onload = function() {
                // Deep link to your app goes here
                document.getElementById("l").src = "my_app://";

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>

If others have better solutions to detect whether the URI scheme call actually failed, please post! I haven't seen one, and I've spent a ton of time looking. All existing solutions just rely on the user still being on the page and the setTimeout firing.

like image 194
st.derrick Avatar answered Oct 13 '22 01:10

st.derrick


here is a code that works on iOs, even if the "Can not open URL" still show.

    window.location = "yourApp://foo/bar";      
    clickedAt = +new Date;
    setTimeout(function() {
        if (+new Date - clickedAt < 2000) {
            window.location = "go to Android market";
        }
    }, 500);

Thanks for the android solution.

like image 36
cyrilchampier Avatar answered Oct 12 '22 23:10

cyrilchampier