游戏中心邀请立即失败 [英] Game Center invite fails immediately
问题描述
我们在使用 GKGameCenterViewController
发送邀请时遇到问题。视图控制器打开就好了,但是当我们尝试向某人发送邀请时,它会立即失败。这两个帐户都启用了游戏中心邀请,并通过 GKGameViewController
查找其他玩家。以下是我们用来管理邀请的代码:
We're having a problem with sending invites with GKGameCenterViewController
. The view controller opens up just fine, but when we try to send an invite to somebody, it immediately fails. Both accounts have game center invites enabled and finding other players through the GKGameViewController
works fine. Here's the code we're using to manage the invites:
只要 GKLocalPlayer
是,就会调用此方法经过身份验证(从 GameViewController
调用身份验证,此代码位于单独的Game Center管理类中):
This method is called as soon as the GKLocalPlayer
is authenticated (authentication is called from GameViewController
, this code is in a separate Game Center managing class):
internal func authenticationChanged() {
if GKLocalPlayer.localPlayer().authenticated && !authenticated {
print("Authentication changed: player authenticated")
authenticated = true
GKLocalPlayer.localPlayer().unregisterAllListeners()
GKLocalPlayer.localPlayer().registerListener(self)
} else {
print("Authentication changed: player not authenticated")
authenticated = false
GKLocalPlayer.localPlayer().unregisterAllListeners()
}
}
这是接收邀请时应该调用的方法,尽管它是考虑到邀请一旦发送就失败,则不会调用。
And this is the method that should be called when the invite is received, although it it isn't called considering that the invite fails as soon as it is sent.
public func player(player: GKPlayer, didAcceptInvite inviteToAccept: GKInvite) {
//presentingViewController.dismissViewControllerAnimated(false, completion: nil)
print("Accepted invite")
let mmvc = GKMatchmakerViewController(invite: inviteToAccept)!
mmvc.matchmakerDelegate = self
presentingViewController.presentViewController(mmvc, animated: true, completion: nil)
}
这两段代码都在同一个类中,符合 GKMatchmakerViewControllerDelegate,GKGameCenterControllerDelegate,GKMatchDelegate,GKLocalPlayerListener
委托和协议。
These two pieces of code are all in the same class that conform to the GKMatchmakerViewControllerDelegate, GKGameCenterControllerDelegate, GKMatchDelegate, GKLocalPlayerListener
delegates and protocols.
推荐答案
我遇到了完全相同的问题。问题似乎是我在应用程序设置中使用了新版本的字符串 - 我将其删回到当前在iTunes Connect中并与Game Center一起工作的版本,它一切顺利!
I was having the exact same problem. The problem appears to be that I was using a new version string in app settings - I dropped this back to a version that is currently in iTunes Connect and working with Game Center and it all works smoothly!
这篇关于游戏中心邀请立即失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!