问题描述
我正在开发具有Gamecenter支持的游戏.我想禁用iPhone 3g或更旧设备的按钮.但是我的3g测试设备说,该游戏中心可用并且显示了配对视图.用户将永远不会得到认证.我使用苹果的代码片段来检查游戏中心是否可用.在3gs以上的设备上应返回NO
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?
推荐答案
显然,检测Game Center支持不只是检查API是否存在.根据可选地在游戏中支持游戏中心,除了检查API外,您还需要对播放器进行身份验证:
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:
这篇关于Apple GameCenter可用测试在iPhone 3G上返回YES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!