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?

PEZ
  • 16,821
  • 7
  • 45
  • 66

3 Answers3

2

Actually, you can check if your application can open one of the gamecenter: URL schemes.

BOOL canOpenGC = [[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@"gamecenter:/me/account]];

See this StackOverflow answer on the matter

Community
  • 1
  • 1
james_womack
  • 10,028
  • 6
  • 55
  • 74
1

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

if (![gcClass localPlayer]) {
    // then you havnt got game center support
}
Nick Hingston
  • 8,724
  • 3
  • 50
  • 59
  • 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 Oct 04 '10 at 20:36
  • 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 Hingston Oct 04 '10 at 20:49
  • 1
    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 Oct 05 '10 at 04:27
  • 1
    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 Hingston Oct 05 '10 at 07:51
  • 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 Oct 05 '10 at 12:51
0

The answer is that you can't. Apple wants us to attempt to login to see if Game Center is there. Odd, but that's how it is.

PEZ
  • 16,821
  • 7
  • 45
  • 66