Apple gamecenter available test returns YES on iphone 3g

若如初见. 提交于 2019-12-12 05:59:52

问题


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 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?


回答1:


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.



来源:https://stackoverflow.com/questions/6098969/apple-gamecenter-available-test-returns-yes-on-iphone-3g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!