[Solved] Can you open an iOS app from an HTTP url scheme?

I would like to open my iOS application similar to how it can be done on Android, that is by using a specific web address instead of a custom URL protocol.

This is how it works on Android. The Reddit is Fun app is a great example of this:

  • User is in their mail app, browser app, or something equivalent.
  • User clicks on a link to a reddit post. For this example, the link is “http://reddit.com/r/example
  • Reddit is Fun app is setup to handle “http://reddit.com/” links
  • Android displays a dialog giving the user these options:
    • Open link in Web Browser
    • Open link in Reddit is Fun

I’ve been trying to find reference material on the Apple iOS URL Schemes, but everything I have found so far indicates that you need to have a custom URL protocol, and that you cannot use http://. You would have to use something like ‘reddit://’.

The great thing about specifying an actual web address as a URL scheme is that if you didn’t have the Reddit is Fun app, the browser would automatically open the page and that would be a great fallback. In the case of using a custom URL protocol like in iOS, if your device does not have the app installed, there is no fallback. There is no indication that it failed. There is no indication that it tried to do anything.

Does anyone know a way to open an application this way? For example, is it possible to open a reddit app when clicking on a ‘http://reddit.com/‘ link?

Edit: What I find very interesting is that iOS already supports this to some extent with YouTube links.

Edit: It looks like there’s no way to do exactly what I want on iOS. However, this post has some good suggestions on what to do. I was hoping things would have changed since 2009.

Solution #1:

This is now enabled on ios in what they’re calling “Universal Links”:
https://developer.apple.com/library/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html

There is a Cordova plugin to support this if your source is html based:
https://github.com/nordnet/cordova-universal-links-plugin#android-web-integration

Respondent: Rick Mortensen

Solution #2:

What you’ve found is correct, it can only be done with a custom scheme.

Respondent: David Berry

Solution #3:

Let me tell you how on iOS it is achieved by most apps I hope ‘Reddit is Fun’ too.

The Http link redirects you to a webpage which checks whether your iOS app is installed, by calling custom URL associated with your app.

If it returns failure the web page is loaded, otherwise the application is launched with specific view.

I hope that is what you were looking for.

Respondent: bllakjakk

Solution #4:

You can actually do this, but it will require you to host a page on your server for every reddit article you want to link to. We built a dynamic version of this ourselves at Branch so that we don’t have to manually create a page each time, and we also detect iOS versus Android. But for manually creating a page, are the steps:

If you want to send an email linking to http://reddit.com/r/example, you need to create a page and host it on your server (e.g. http://yourapp.com/hosted-links/r/example). It should look like this:

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

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "http://reddit.com/r/example";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>

Now you can link to your server, http://yourapp.com/hosted-links/r/example, and it will open appropriately on iOS whether the user has the app or not.

Respondent: st.derrick

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.