Skip to content

Instantly share code, notes, and snippets.

@typeoneerror
Created October 14, 2010 05:07
Show Gist options
  • Save typeoneerror/625607 to your computer and use it in GitHub Desktop.
Save typeoneerror/625607 to your computer and use it in GitHub Desktop.
/**
* 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);
}
@PEZ
Copy link

PEZ commented Oct 20, 2010

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment