Created
October 14, 2010 05:07
-
-
Save typeoneerror/625607 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determines if the device running this | |
* application is Game Center ready. | |
* | |
* @return true if Game Center is available. | |
*/ | |
BOOL isGameCenterAvailable(); | |
#import <sys/utsname.h> | |
BOOL isGameCenterAvailable() | |
{ | |
// Check for presence of GKLocalPlayer API. | |
Class gcClass = (NSClassFromString(@"GKLocalPlayer")); | |
// 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); | |
// 1st Gen iPod and 3G don't support Game Center | |
struct utsname systemInfo; | |
uname(&systemInfo); | |
NSString *theModel = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; | |
if ([theModel isEqualToString:@"iPhone1,2"] || | |
[theModel isEqualToString:@"iPod1,1"]) | |
{ | |
return FALSE; | |
} | |
return (gcClass && osVersionSupported); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing!