Turning off GameCenter support in OpenFeint

Today I realize that Apple’s GameCenter only works with iOS 4.0+… indeed I was already aware of this, but I forgot! -.-”

When I tried to test game on iPad 3.0 I received an NSException error…

I use OpenFeint in my game, but in the last release OF has included the GC support…i don’t want it! How remove it? First of all, you have to soft link the framework:

in XCode go to Project->Edit Active Target. Click on General tab, and in Linked Libraries select Weak link for GameKit.framework.

After you have to disable GC in OF settings: in the initialization, in the NSDictionary passed to OF, insert this line

[NSNumber numberWithBool:NO], OpenFeintSettingGameCenterEnabled,

like this:

NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:
	[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight],
OpenFeintSettingDashboardOrientation,
	@"APPNAME", OpenFeintSettingShortDisplayName,
	[NSNumber numberWithBool:YES], OpenFeintSettingEnablePushNotifications,
	[NSNumber numberWithBool:NO], OpenFeintSettingDisableUserGeneratedContent,
  	[NSNumber numberWithBool:NO], OpenFeintSettingAlwaysAskForApprovalInDebug,
	[NSNumber numberWithBool:NO], OpenFeintSettingGameCenterEnabled,
	window, OpenFeintSettingPresentationWindow,
	nil];

Instead, if you want to check at run time whether GC is supported on that device, write this code:

Class SomeGameKitClass = NSClassFromString(@"GKAchievement");

...

[NSNumber numberWithBool:(SomeGameKitClass != NULL)],
     OpenFeintSettingGameCenterEnabled,

In this way, if device support GC it will enable, otherwise no 🙂 .

Another thing:

on iOS 4.0 GC is not fully implemented…only since iOS 4.1…you must also check this! This is a simple code that does this:

// The device must be running running iOS 4.1 or later.
NSString *reqSysVer = @"4.1";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported =
     ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);

And this is all, see you soon! 🙂

via: http://openfeint.com/developers/forum/showthread.php?2247-Detecting-and-turning-off-GCenter-when-on-NON-iOS-4-1-device
Advertisements
This entry was posted in iOS and tagged , , . Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s