开发者

Apple gamecenter available test returns YES on iphone 3g

I'm making a game with gamecenter support. I want to diable a button for iPhone 3g or older devices. But my 3g test device says, that gamecenter is available and the matchmaking view show up. The user will never get authenticated. I use the snippet from apple 开发者_Go百科to check, if gamecenter is available. It should return NO on devices older than 3gs

-(BOOL)isGameCenterAvailable {
// check for presence of GKLocalPlayer API
Class gcClass = (NSClassFromString(@"GKLocalPlayer"));

// check if the device is running iOS 4.1 or later
NSString *reqSysVer = @"4.1";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer 
                                       options:NSNumericSearch] != NSOrderedAscending);

return (gcClass && osVersionSupported); }

Does anyone do it better than apple?


Apparently, there is more to detecting Game Center support than just checking for the existence of the API. According to Optionally Supporting Game Center In Your Game, in addition to checking for the APIs you'll also need to authenticate the player:

iOS 4.1 may be installed on some devices that do not support Game Center. On those devices, the isGameCenterAPIAvailable function defined Listing 1-1 still returns YES. The next step in confirming whether Game Center may be used on the device is to attempt to authenticate the local player; on devices that do not support game center, your game receives a GKErrorNotSupported error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜