PEZ
PEZ

Reputation: 17004

How to detect Game Center support?

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?

Upvotes: 1

Views: 858

Answers (3)

james_womack
james_womack

Reputation: 10296

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

Upvotes: 2

PEZ
PEZ

Reputation: 17004

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.

Upvotes: 0

Nick Hingston
Nick Hingston

Reputation: 8880

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

if (![gcClass localPlayer]) {
    // then you havnt got game center support
}

Upvotes: 1

Related Questions