This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
tutorials:using_openfeint_with_sparrow [2011/12/30 00:24]
tutorials:using_openfeint_with_sparrow [2013/03/05 10:19] (current)
Line 1: Line 1:
 +===== Using OpenFeint with Sparrow =====
 +[[/​users/​brian/​start|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.
 +\\ [[http://​forum.sparrow-framework.org/​topic/​tutorial-integrating-openfeint-with-sparrow|Tutorial Forum Post]]
 +This tutorial starts with the Sparrow scaffold. If you are not using the scaffold, your integration might be a little different.
 +== 1. Go to https://​api.openfeint.com/​dd/​signup and sign up for an account. ==
 +\\ If you already have an account, just create a new game from the developer dashboard.
 +== 2. Download the latest SDK from https://​api.openfeint.com/​dd/​downloads. ==
 +I am using the OpenFeint iOS 2.12.5 package.
 +== 3. Find OpenFeint.framework in the SDK package and add it to your Sparrow project. ==
 +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.
 +\\ {{http://​img838.imageshack.us/​img838/​9762/​screenshot20111229at115.png?​300|}}
 +== 4. Add the following frameworks to your project. ==
 +\\ 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.
 +== 5. Add the following code in ApplicationDelegate.h and .m. ==
 +<code objc>
 +#import "​OpenFeint/​OpenFeint.h"​
 +// Add OpenFeintDelegate after UIApplicationDelegate
 +@interface ApplicationDelegate : NSObject <​UIApplicationDelegate,​ OpenFeintDelegate>​
 +<code objc>
 +// At the end of applicationDidFinishLaunching
 +NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:​
 +[NSNumber numberWithInt:​UIInterfaceOrientationPortrait],​ OpenFeintSettingDashboardOrientation,​
 +@"​OFSparrow",​ OpenFeintSettingShortDisplayName,​
 +#ifdef DEBUG
 +[NSNumber numberWithInt:​OFDevelopmentMode_DEVELOPMENT],​ OpenFeintSettingDevelopmentMode,​
 +[NSNumber numberWithInt:​OFDevelopmentMode_RELEASE],​ OpenFeintSettingDevelopmentMode,​
 +[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];
 +== 6. Use these methods to open the OpenFeint dashboard. ==
 +<code objc>
 +// You may need to #import "​OpenFeint/​OpenFeint+Dashboard.h"​
 +[OpenFeint launchDashboard];​
 +[OpenFeint launchDashboardWithListLeaderboardsPage];​
 +[OpenFeint launchDashboardWithHighscorePage:​@"​leaderboardID"​];​
 +[OpenFeint launchDashboardWithAchievementsPage];​
 +[OpenFeint launchDashboardWithFindFriendsPage];​
 +[OpenFeint launchDashboardWithWhosPlayingPage];​
 +== 7. Use these methods to submit scores and achievements. ==
 +<code objc>
 +// 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];​
 +== 8. Yay! You're done. ==
 +Here is the sample project from this tutorial.
 +\\ [[http://​cl.ly/​0l3b3E1q2d3c0A2M0h29|Sample Project]]
Powered by DokuWiki