I'm adding Game Center support to my game. Because my game can run on iOS versions back to 3.0, I want to have it fallback to just saving achievements and leaderboards locally in the absence of Game Center.
Right now, I have this:
+ (BOOL) isGameCenterAvailable {
Class playerClass = NSClassFromString( @"GKLocalPlayer" );
if( playerClass != nil && [playerClass localPlayer] != nil ) {
DebugLog( @"Game Center is available" );
return YES;
}
DebugLog( @"Game Center is NOT available" );
return NO;
}
However, this appears not to work at all. For one thing, despite the GKLocalPlayer reference stating that this class is available in iOS 4.1 and higher, the above test passes in iOS 4.0 (I didn't try earlier versions). For another thing, the test also passes on devices which have iOS 4.1, but which otherwise don't support Game Center (for example, an iPhone 3G).
I've gone through the various GameKit and Game Center docs online, and haven't had any luck figuring this out. I could certainly detect the OS version, but that seems lame. That also wouldn't help for the case of unsupported hardware (like a 3G). That could also be detected I suppose, but again, seems kinda lame.
What's the "right way" to programmatically detect Game Center support?