views:

60

answers:

1

In Apples documentation for Game Center it says to use this code to detect if Game Center is available:

+ (BOOL) isGameCenterAvailable {
  Class gcClass = (NSClassFromString(@"GKLocalPlayer"));

  NSString *reqSysVer = @"4.1";
  NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
  BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);

  return (gcClass && osVersionSupported);
}

But it returns YES on my iPhone 3G which doesn't have Game Center. Anyone out there who has solved this?

+1  A: 

I have not tried this, but try getting the local player singleton:

if (![gcClass localPlayer]) {
    // then you havnt got game center support
}
Nick H247
Thanks, but that doesn't work either. It seems like Apple planned to support Game Center on the 3G, but pulled it last second or something...
PEZ
You will never be able to get authenticated on a 3G phone...so as long as you are testing for this, then it shouldn't be a problem what hardware you are on.
Nick H247
Problem is that if I attempt to authenticate then the user on a supported device will get a login dialog. That dialog doesn't say anything about Game Center (don't know why Apple did it like that). I try to deal with that by providing a button that initiates Game Center features for the app. And I don't want to show that button if game center is not available.
PEZ
very odd..sounds like apple have really f'd that up! it is possible to find out which device you are actually running on, but i cant believe you're expected to do that. see sysctlbyname...
Nick H247
I guess it'll either come to that or that the 3G users of my app will have that button anyway and get an error message when they try it.
PEZ