Friday, May 18, 2012

Facebook iOS application url scheme problem

I am working on an iOS application that handle some url schemes. Let say that you want to allow your users to open from your app the Facebook app.

    NSURL *facebookURL = [NSURL URLWithString:@"fb://"];
    if([[UIApplication sharedApplication] canOpenURL:facebookURL]){
        [[UIApplication sharedApplication] openURL:facebookURL];

This code above is working with no problem  if you have Facebook app installed on your iOS device.

Now the tricky part appears when the user has installed Superonic HD or  Supersonic and has no Facebook application on the device the code will open Supersonic game even if the user installs the Facebeook application after supersonic.

If the user deletes the supersonic game the Facebook application will still not be opened because the code will not pass the if condition.

The fix is to delete Facebook application and Supersonic game, install the Facebook application first and then Supersonic game.

So if you are an developer that uses Facebook URL scheme you know what to expect, if you are an iPhone user and you have apps that open Supersonic instead of Facebook you know that is not the application fault, but the Supersonic application that registered the same URL schemes Facebook.

If you write an application that will have an URL scheme and you think that in the future you will make it public try to choose something that is unique and that will be very hard to be copied by others. Because if Facebook used a url scheme like "facebook://" then will be hard for other applications to have the same URL scheme and even if they had the same scheme they could not say that this was a mistake and not an intended action.

Advice for those who write an application with an URL scheme try to make it as clear as possible that the scheme used it is yours. Because if all applications will use 2 letter scheme the rewrite of URL scheme it is inevitable on how many application are in store.

Hopefully Apple will impose some rule in the future for the URL scheme naming.

If you have an application and you want others to use it you can add it to the iPhone URL Schemes akosma wiki.


  1. Wow this site is really amazing and inspirational to me, i am glade to meet this site.
    Facebook Development

    1. Thanks Angelina, unfortunately I don't have enough time to invest in it.