FacebookScorer – Post highscores to user’s Facebook Wall

Today’s post is an update for an old article about posting high scores to Facebook Wall. Some users have reported some issues about this class. There were some problems with the state control when authorization was needed.

Today I will like to post a new version of the class that solves these issues. The project is now called FacebookScorer and you can find it on GitHub.

Facebook icon_big

With FacebookScorer you can post scores for your game on Facebook Wall on user’s behalf in a single line of code.

Facebook Post


FacebookScorer offers the following features:

  • Publish scores to Facebook Wall with the Facebook Dialog
  • Handles automatically login and authorize on Facebook


1 – Add the FacebookScorer folder to your Xcode project.

2 – Add the following methods to your app Delegate: (remember to include FacebookScorer.h)

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url];

// For 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url];

3 – Add “URL Types” array as shown on the image below to your Info.plist file. You will need to introduce your Facebook’s app ID in the “URL identifier” and “URL Schemes” fields. Notice the “fb” prefix in “URL Schemes”.

plist Facebook


There is a simple Demo app within the project.

On top of the FacebookScorer.m file you will find the constants to be customized, including your Facebook app ID:

static NSString* kAppId = @"000000000000000"; // Your Facebook app ID here

#define kAppName        @"Your App's name"
#define kCustomMessage  @"I just got a score of %d in %@, an iPhone/iPod Touch game by me!"
#define kServerLink     @"http://indiedevstories.com"
#define kImageSrc       @"https://indiedevstories.files.wordpress.com/2011/08/newsokoban_icon.png"

Then, simply add this line of code where you want the Facebook dialog to appear:

[[FacebookScorer sharedInstance] postToWallWithDialogNewHighscore:123];

Done! As usual, very easy to use 😉



About Toni Sala

Indie game designer and developer
This entry was posted in Home, idevblogaday, Tutorials and tagged , , , , , , , , , . Bookmark the permalink.

27 Responses to FacebookScorer – Post highscores to user’s Facebook Wall

  1. Thank’s for sharing!!.

    Very useful code.

  2. Thank you, it works great!

  3. Toni Sala says:

    You are welcome! :^]

  4. Pingback: List of Open Source Cocos2d Projects, Extensions and Code Snippets | iUridium

  5. Nnob says:

    I got the FB app popup but then it logs me out from FB app. Also if I want the dialog stay in my game, what should I do?

    • Nnob says:

      Update: I had a very old version of FB app on my iPhone. After I updated it, my game launches FB app (w/o logging me out from FB app), but it did not bring the post status dialog 😥

  6. Nnob says:

    Actually I forgot to changed fb app ID from the .plist file. It works great now. Thank you very much!.

  7. Toni Sala says:

    Perfect 🙂

    Hope you enjoy it 😀

  8. Tommy says:

    Hi Toni and thanks for sharing!
    I have tried to use your demo app but after it launches FB add user accept the app it does not post the message and return to the app. instead it stays in FB. In fact I do not get any callback as a result of this: [_facebook requestWithGraphPath:@”me” andDelegate:self];

    Any ideas what I’m doing wrong?
    Where should I add the FB app secret? Currently I have only added FB app id in the FacebookScorer.m and in the plist file URS Scheme. What should I add in the URL identifier?

  9. Toni Sala says:


    I have just re-read your previous comment and saw that you asked: ” What should I add in the URL identifier?”

    Do you mean in the plist file? If so, it is again the app ID. You need to insert the app ID twice in the plist file. In the URL Identifier field without the “fb” prefix.


  10. Jim says:

    Awesome, this is exatcly what I needed for my apps. Works great!

  11. David Hegner says:

    Thank you for this, everything works great, it was very easy to modify for my personal needs and is a lot less convoluted than a lot of other solutions out there.

  12. Jonhy da Silva says:

    Thank you, it was a success, just one more thing, there is a way to the users log out of the facebook and uses another account to post on his wall ???

    Thank you!!

  13. Toni Sala says:

    Hi @Jonhy,

    You could use the “logout” method of the Facebook class like so:

    [[[FacebookScorer sharedInstance] facebook] logout];

    HTH :^]

    • Jonhy da Silva says:

      I have a new problem Toni, when i run the app on the simulator on the mac, it works good, but when i run on the device, it does not work, the facebook opens my facebook`s timeline and not the “window” to post high score.

  14. Damian says:

    Great tutorial and library! I managed to get the demo working and post to my Facebook page. When I try to implement the code in my own iPhone app I get a whole stack of errors about “‘release’ is unavailable in automatic reference counting mode”, “ARC forbids explicit message send of ‘release'”, etc. I am using the latest iPhone 5.1 SDK with XCode 4.3.1. Any suggestions?

  15. Joey van den Brink says:

    Wow thanks! Really works out of the box.
    I just made a minor mistake by entering the fb000 into the field where it shouldn’t have a prefix.

    Thanks a lot!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s