Opening The Facebook App To Your Facebook Fan Page

By
On January 6, 2010
Guest author Robert Strojan (@blackoutrobb) is the founder and lead iPhone app developer at Blackout Labs. He is also a speaker at the 360|iDev Conference in April.

In September I wrote a post on iPhoneDevTools.com about opening the Facebook iPhone app from within another app or from the web with the Facebook app’s custom URLs. I got a lot of questions about how to open the Facebook app directly to a fan page or application page allowing an app’s users to add themselves as Facebook fans.

The most widely used method of opening a Facebook fan page is to open it in Safari or an in-app browser. The issue with this method is that iPhone users likely use the Facebook iPhone app and, consequently, won’t be logged-in in the browser. The extra hurdle of logging in is a significant factor in app-to-Facebook-fan conversion rates. It would be nice to open the Facebook app directly to a fan page allowing the user to add themselves as a fan in a single tap. Here’s how:

The Facebook app is accessible via the custom URL protocol ‘fb://’. There are several domains you can add next to access different parts of the Facebook app. One is ‘profile’. A specific profile can be opened by adding the unique ID of the fan page as a path to the domain. Here’s how I open my recently created Blackout Labs fan page:

I got my Blackout Labs Fan page unique ID by looking at the address bar of my Fan Page:

Some pages won’t have an ID in the address bar. For those, click on your Fan Page profile pic and on the profile pic page you’ll see the parameter ‘id=’ in the address bar which indicates your fan page’s ID.

Now I can open the Blackout Labs fan page directly in the Facebook app with URL fb://profile/210227459693. If you’re currently browsing on the iPhone, tap that link to open the Facebook app directly to my fan page. Here’s what you’ll see:

The Objective-C code is simple: Open the URL with an instance of ‘sharedApplication’. An if-statement ensures that the fan page will open in Safari if the user doesn’t have the Facebook app installed.

NSURL *fanPageURL = [NSURL URLWithString:@"fb://profile/210227459693"];

if (![[UIApplication sharedApplication] openURL: fanPageURL]) {
        //fanPageURL failed to open.  Open the website in Safari instead
        NSURL *webURL = [NSURL URLWithString:@"https://www.facebook.com/pages/Blackout-Labs/210227459693"];
        [[UIApplication sharedApplication] openURL: webURL];
}

The method also works for Facebook apps. If you’ve created an iPhone app that utilizes Facebook connect, then you already have a fan page setup for your app. You can use the same method above to open your Facebook Connect application’s fan page.

Now I wish I could end it there. I’m not affiliated with Facebook and unfortunately, this information hasn’t yet been officially released by Facebook; possibly because the URLs are not yet stable enough for use. I’ve actually encountered a couple bugs in the process of using the URL including the “Become a Fan” button not appearing consistently and my fan page details not showing up every time the app is opened via a custom URL. Furthermore, the URLs aren’t guaranteed to be supported in future versions of the Facebook iPhone app. In other words, make sure you test your implementation with your Facebook fan or app page, and weigh the risks of possible bugs and future incompatibility with the potential of increased fan conversion rates.

Thanks to Robert for contributing this piece! Want to contribute something? Send your topic and a writing sample to dan at mobileorchard.com

0 responses to “Opening The Facebook App To Your Facebook Fan Page”

  1. Timos says:

    Great information – thanks. I am wondering if this works as a link on a mobile web page displayed in a UIWebView? That would be one way to not have to worry about releasing an app that may not work in the future.

  2. Great article thanks for sharing this news really was waiting for it

  3. Jeff Swanson says:

    Considering the fact that Fan Pages are open to the public, is there a way to get an rss feed of the wall, so that it can be used in an iphone app?

    I understand privacy concerns with other pages, but Fan Pages don’t require login, so you would think they’d be open for this. Any thoughts?

  4. Jens Ljungkvist says:

    This doesn’t work.

    I even tried the link on this page in my iPhone. You can open your own profile and your own albums. But the Facebook app disregards the variable you send it.
    It would be a really cool feature, though!

    /Jens