iphone - 如何检测Game Center支持?

标签 iphone ios game-center

在Apple的Game Center文档中,它说使用此代码来检测Game Center是否可用:

+ (BOOL) isGameCenterAvailable {
  Class gcClass = (NSClassFromString(@"GKLocalPlayer"));

  NSString *reqSysVer = @"4.1";
  NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
  BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);

  return (gcClass && osVersionSupported);
}

但是它在没有Game Center的iPhone 3G上返回YES。有人解决了这个问题吗?

最佳答案

实际上,您可以检查您的应用程序是否可以打开以下游戏中心之一:URL方案。

BOOL canOpenGC = [[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@"gamecenter:/me/account]];

See this StackOverflow answer on the matter

关于iphone - 如何检测Game Center支持?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3858303/

相关文章:

ios - 如何在iPhone中实现单选按钮?

ios - 重建应用程序时推送 token 会改变吗?

iphone - Xcode 4 : how to implement game center achievements?

swift - 如何快速将GameCenter放到应用程序上?

iphone - iOS 的室内导航硬件/软件要求

iphone - [NSManaged对象名称] : unrecognized selector sent to instance 0x6b77240'

iphone - ios UIActivityViewController不附加发送短信的图像

ios - 查找是否已存在 Google+、Fb、Linkedin 和 Twitter 应用

iphone - 为客户、我们的开发帐户构建应用程序还是为他们设置一个?

objective-c - 如何删除有 0 个参与者的 Game Center 游戏