My Wiki Page
OpenFeint is a powerful social framework for iOS games. It makes it easy to handle achievements, leaderboards, and sharing. You can even synchronize it with Game Center. This tutorial only covers a basic OpenFeint integration and not any advanced features.
This tutorial starts with the Sparrow scaffold. If you are not using the scaffold, your integration might be a little different.
I am using the OpenFeint iOS 2.12.5 package.
Also, add the correct configuration bundles for your project:
If your game is iPhone landscape only, use OFResources_iPhone_Landscape.bundle.
If your game is iPhone portrait only, use OFResources_iPhone_Portrait.bundle.
If your game is iPad only, use OFResources_iPad.bundle.
If your game is iPhone landscape and portrait, use OFResources_iPhone_Universal.bundle.
All others use OFResources_Universal.bundle.
AddressBook
AddressBookUI
CFNetwork
CoreLocation
CoreText
GameKit
libsqlite3.0.dylib
MapKit
MobileCoreServices
Security
SystemConfiguration
At this point, you should be able to build and run your app with no OpenFeint related warnings or errors.
ApplicationDelegate.h
#import "OpenFeint/OpenFeint.h" // Add OpenFeintDelegate after UIApplicationDelegate @interface ApplicationDelegate : NSObject <UIApplicationDelegate, OpenFeintDelegate>
ApplicationDelegate.m
// At the end of applicationDidFinishLaunching NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:UIInterfaceOrientationPortrait], OpenFeintSettingDashboardOrientation, @"OFSparrow", OpenFeintSettingShortDisplayName, #ifdef DEBUG [NSNumber numberWithInt:OFDevelopmentMode_DEVELOPMENT], OpenFeintSettingDevelopmentMode, #else [NSNumber numberWithInt:OFDevelopmentMode_RELEASE], OpenFeintSettingDevelopmentMode, #endif nil]; [OpenFeint initializeWithProductKey:@"qXprwYNXTJYdg1iT4lK9Eg" andSecret:@"xgVwRmTkhmOn5StvYiOruIDmL8dEEUyCniZgmLTn0o" andDisplayName:@"OpenFeint Sparrow" andSettings:settings andDelegates:[OFDelegatesContainer containerWithOpenFeintDelegate:self]]; // Add these methods also - (void)dashboardWillAppear { [mSparrowView stop]; } - (void)dashboardDidDisappear { [mSparrowView start]; } - (void)userLoggedIn:(NSString *)userId { NSLog(@"User %@ logged into OpenFeint", userId); } // In the dealloc method [OpenFeint shutdown];
// You may need to #import "OpenFeint/OpenFeint+Dashboard.h" [OpenFeint launchDashboard]; [OpenFeint launchDashboardWithListLeaderboardsPage]; [OpenFeint launchDashboardWithHighscorePage:@"leaderboardID"]; [OpenFeint launchDashboardWithAchievementsPage]; [OpenFeint launchDashboardWithFindFriendsPage]; [OpenFeint launchDashboardWithWhosPlayingPage];
// You may need to #import "OpenFeint/OFHighScoreService.h" and "OpenFeint/OFAchievement.h" [OFHighScoreService setHighScore:100 forLeaderboard:@"leaderboardID" onSuccessInvocation:nil onFailureInvocation:nil]; [[OFAchievement achievement:@"achievementID"] updateProgressionComplete:100.0f andShowNotification:YES];
Here is the sample project from this tutorial.
Sample Project