游戏中心不使用验证雨燕 [英] Game Center not authenticating using Swift

查看:242
本文介绍了游戏中心不使用验证雨燕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试进行身份验证使用SWIFT的本土球员,但每次我得到了.authenticated属性值为false。这里是code我使用的,它是由主视图控制器称为应用程序启动时。

I'm trying to authenticate the local player using swift, but every time I get a false value for the .authenticated property. Here is the code I'm using, it is called by the main view controller when the app starts.

func authenticateLocalPlayer(){
  var localPlayer = GKLocalPlayer()
  localPlayer.authenticateHandler = {(viewController, error) -> Void in
    if viewController {
      self.presentViewController(viewController, animated: true, completion: nil)
    }else{
      println((GKLocalPlayer().authenticated))
    }
  }
}

这将在日志中查看就好了,但是当我进入一个测试帐号登录,它只是返回的 GKLocalPlayer()。验证为假。在iTunes Connect的包标识符和Info.plist中是完全一样的,因为是版本和应用程序名称。一切都是游戏中心在iTunes Connect和以x code启用,但是我有一种感觉这不是一个编码错误,它在应用程序记录安装错误的地方,但我不能为我的生活中寻找到。

It brings up the log in view just fine, but when I enter a test account login, it just returns the GKLocalPlayer().authenticatedas false. The bundle identifier in iTunes Connect and the info.plist are exactly the same, as is the version and the app name. Everything is enabled for Game Center on iTunes Connect and in Xcode, but I have a feeling it's not a coding error, it's a setup error in the app record somewhere but I can't for the life of me find where.

在进一步的修修补补,我得到这个错误:

After further tinkering, I'm getting this error:

错误域= GKErrorDomain code = 15请求的操作无法完成,因为该应用程序不被游戏中心的认可。的UserInfo = {0x17006b300 = NSLocalizedDescription请求的操作无法完成,因为该应用程序不被游戏中心的认可。}

Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognized by Game Center." UserInfo=0x17006b300 {NSLocalizedDescription=The requested operation could not be completed because this application is not recognized by Game Center.}

我不知道为什么是这种情况,包ID,名称和版本的所有比赛...

I have no idea why this is the case, the bundle ID, name and versions all match...

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

推荐答案

此问题已被苹果解决 - 只要致电:

This issue has been resolved by Apple - just call:

GKLocalPlayer.localPlayer()

previously,问题是, GKLocalPlayer()不返回GKLocalPlayer单,而是返回一个新的GKLocalPlayer实例。

Previously, the issue was that GKLocalPlayer() does not return the GKLocalPlayer singleton, but instead returns a new GKLocalPlayer instance.

如果你是在X code 6测试版,您可以添加一个返回真正的GKLocalPlayer单C函数或Objective-C的方法,那么在斯威夫特使用。这是我的解决办法的要点(坏命名惯例):

If you were on the Xcode 6 BETA, you could add a C function or Objective-C method that returns the real GKLocalPlayer singleton, then use this in Swift. This is the gist of my workaround (with bad naming conventions):

在一个Objective-C头:

In an Objective-C header:

GKLocalPlayer *getLocalPlayer(void);

在一个Objective-C实现的:

In an Objective-C implementation:

GKLocalPlayer *getLocalPlayer(void) {
    return [GKLocalPlayer localPlayer];
}

在你的桥接报头:

#import "ThatHeader.h"

然后,每当你需要访问GKLocalPlayer单斯威夫特,你可以使用 getLocalPlayer()而不是 GKLocalPlayer()。这可能是一个更好的主意坚持,在GKLocalPlayer类别的方法。

Then whenever you need to access the GKLocalPlayer singleton in Swift, you can just use getLocalPlayer() instead of GKLocalPlayer(). It's probably a better idea to stick that in an method of a GKLocalPlayer category.

然而,这不再是必要的,因为上面详述

However, this is no longer necessary as detailed above.

这篇关于游戏中心不使用验证雨燕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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