Wednesday, April 11, 2012

iPhone: fb://... URL opening the Premier Inn app, not Facebook

I don't know a lot about how the iOS handles URLs, but it appears to be doing something strange on my phone...


We have a 'Like' button in our app, that when clicked on is supposed to open the Facebook application (or Safari, if Facebook is not installed). For some reason, when I click it on my phone, it opens the "Premier Inn" app. I have both the Facebook App and Premier Inn app installed on my phone, but not sure why Facebook isn't opening when the following code is executed:


NSURL *fanPageURL = [NSURL URLWithString:@"fb://page/BIG_NUMBER_HERE"];
 
 if (![[UIApplication sharedApplication] openURL: fanPageURL]) { ... }
 


For obvious reasons, I've substituted the page number for BIG_NUMBER_HERE in the above code.


Can anyone explain why this might be going wrong? Could the Premier Inn app have "registered" itself as a handler of the fb:// urls somehow?


Regards,



Answer:

Just as you suggest, it sounds like Premier Inn has registered as a handler for "fb". There's no central registry to stop applications from using the same URL scheme, it's really just down to good luck and reasonable namespace choices by developers.
Edit: I can't find a canonical source for this, but the handler application that's called is that which is most recently installed.

No comments:

Post a Comment