Apple GameCenter可用测试在iPhone 3G上返回YES [英] Apple gamecenter available test returns YES on iphone 3g

查看:57
本文介绍了Apple GameCenter可用测试在iPhone 3G上返回YES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发具有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:

iOS 4.1可能已安装在某些操作系统上不支持游戏的设备中心.在这些设备上,isGameCenterAPI可用功能定义的清单1-1仍返回YES.下一步确认可以在设备上使用Game Center是试图验证本地玩家;在没有的设备上支持游戏中心,您的游戏收到GKErrorNotSupported错误.

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.

这篇关于Apple GameCenter可用测试在iPhone 3G上返回YES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆