Jan 14

We all know about the feature to register a custom URL scheme in Info.plist so that when Safari tries to open myapp://some?parameters, your app will be launched. This is very useful, but has it’s clear limitations.

Today I downloaded Apple’s new MobileMe Gallery app. At one point the app asked me if I wanted to always open MobileMe galleries in the app, instead of showing the web version. When I said “sure”, the app launched Safari which greeted me with a page that exclaimed: “Safari is now configured to use the MobileMe Gallery app.”

The result of this magic trick is that now when I go to a URL like this: http://gallery.me.com/something/000000, Safari launches the MobileMe Gallery app.

This is different from the custom URL scheme registration we all know and love:

  • A new URL scheme was not registered, it uses http:
  • Not all URLs starting with http: were taken over, just those associated with MobileMe galleries.
  • The registration was done dynamically.
  • I had a say in if I wanted this to happen or not.
  • It seems to rely on some undocumented feature in Mobile Safari.

Why would this be useful in your own apps?

  • On a web page you can create a link that will launch your app on the device if it has been installed. If the app is not installed you can display a web page that entices the user to purchase the app from the App Store.
  • Say you have a news reader app and you share a link to a news story with a friend via email. If your friend also has the app installed then the news story can display nicely in the app. If not, then Safari will be launched and your friend will see the web version of the news story.

With custom URL schemes both of the above scenarios would require two different links and force the user to select the right one based on their situation. Tap the wrong link and you’ll get an error message. Not pretty.

Apple, can you please document and expose this functionality to us mere mortals?
Update: Turns out that this feature does not rely on any private API:s. Read Brian’s comment below to learn how it’s done.

written by Nick \\ tags: