1

I have a page where I want to redirect users to the Instagram app when it's installed. That part works well, but when the user doesn't have the app installed it prompts them to go to the app store and download the app, which is not what I want.

I'm seeing this behavior on OS X in Safari, and the HTML involved is ({username} would be populated by my application based on the user submitting the form):

<!DOCTYPE html>
<html lang="en">
    <head>
      <meta http-equiv="refresh" content="0; url=instagram://user?username={username}">
    </head>

    <body>
        <div>
            Taking you to Instagram...
        </div>
        <script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">
        $(function() {
            setTimeout(function() {
              window.location = "https://instagram.com/{username}";
            }, 200);
        });
        </script>
    </body>
</html>

EDIT Specifically, what's happening is the line <meta http-equiv="refresh" content="0; url=instagram://user?username={username}"> is showing the following dialog:

enter image description here

I'd like for that dialog not to display and let the "window.location =" in the take over and redirect the user to Instagram within the browser.

My question is how can I modify the "instagram://" redirect to not ask users to install the Instagram app on their machine?

Eric Hydrick
  • 3,467
  • 2
  • 28
  • 41
  • If a user doesn't have instagram installed what should it do then? – l'L'l May 04 '15 at 12:59
  • The Javascript function in the tag will redirect them to instagram.com in their web browser. That part works - you can see it if you run the HTML in Chrome. In Safari, it asks you if you want to open the app store so you can install the Instagram app. – Eric Hydrick May 04 '15 at 13:02
  • In Safari it tells me "There is no application set to open the URL instagram://user?username=null" ... with ` or ` – l'L'l May 04 '15 at 13:10
  • Yes - that's the dialog I'm trying to get to not appear. – Eric Hydrick May 04 '15 at 13:11
  • If that didn't appear what would be the desired alternative though? – l'L'l May 04 '15 at 13:12
  • The "Taking you to Instagram..." page would load and the window.location = "https://instagram.com/{username}" line would redirect you to Instagram within the browser. – Eric Hydrick May 04 '15 at 13:13
  • Even if they didn't have the instagram app installed? – l'L'l May 04 '15 at 13:14
  • Correct - even if they don't have the app installed. – Eric Hydrick May 04 '15 at 13:15
  • http://stackoverflow.com/questions/24571548/javascript-how-to-detect-if-the-custom-url-scheme-is-available-or-not-availabl Does this help? – Doon May 04 '15 at 13:19
  • @Doon not really. It stops the dialog from appearing, but when I test using a mobile device that has Instagram installed, Instagram doesn't launch, which is what I'd like to see happen in that scenario. – Eric Hydrick May 04 '15 at 16:21

1 Answers1

1

There is no (official) way to detect in the browser if an app (like Instagram) is installed and thus you cannot use a custom url scheme without offering an alternative. You should let the choice to the end-user and prompt to open the website (https scheme) or the app (Instagram scheme). The user will know if the app is installed.

If you know already that the user has the Instagram app installed, you can look at the browser agent to see if you are on an iOS device.

pizzamonster
  • 1,141
  • 10
  • 9