我们发送邀请时遇到问题GKGameCenterViewController.视图控制器打开就好了,但是当我们尝试向某人发送邀请时,它会立即失败.两个帐户都启用了游戏中心邀请,并通过GKGameViewController工作找到其他玩家.这是我们用来管理邀请的代码:
一旦GKLocalPlayer经过身份验证就调用此方法(从中调用身份验证GameViewController,此代码位于单独的Game Center管理类中):
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()
}
}
Run Code Online (Sandbox Code Playgroud)
这是收到邀请时应该调用的方法,尽管考虑到邀请一发送就失败就不会调用它.
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)
}
Run Code Online (Sandbox Code Playgroud)
这两段代码都在符合GKMatchmakerViewControllerDelegate, GKGameCenterControllerDelegate, GKMatchDelegate, GKLocalPlayerListener委托和协议的同一个类中.
我创建了一个以编程方式使用实时多人游戏的游戏.它最初的目标是针对IOS 8设备.最近在迁移到IOS 9后,Game Center引发了很多问题.我无法解决的主要问题是在多人游戏中邀请朋友(用于测试).
从IOS 8到IOS 8.自动匹配工作和朋友邀请工作但是从IOS 9到IOS 9.自动匹配工作和朋友邀请不再起作用.
如果您有任何人设法让IOS 9上的Game Center邀请工作.请引导我走正确的道路.
我目前所知道的:
更新 - 9/10/15 他们关闭了IOS 8的沙盒后.自动匹配已经开始在IOS8和IOS9之间工作.但这位朋友似乎还是个问题.这位朋友也在IOS 8上停止了为我工作.
Game Center回调似乎在不同的线程上运行,导致连接崩溃的几率为80%.解决方案是在主线程上运行代码并解决它.但是线程问题并没有解决朋友的问题.
尝试与朋友请求开始匹配后,它会抛出一个错误,如下所示:
Error Domain=GKErrorDomain
Code=3
"The requested operation could not be completed due to an error communicating with the server."
UserInfo={
GKServerStatusCode=5096,
NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.,
NSUnderlyingError=0x136e23230 {
Error Domain=GKServerErrorDomain
Code=5096
"Peer device (type: iPad) does not support a …Run Code Online (Sandbox Code Playgroud) 我正在通过游戏中心开展多人游戏,我遇到了一个问题.当我试图邀请我的一个朋友时,我失败了.我尝试过使用模拟器和iphone以及两部iphone并且始终存在同样的问题.
我搜索了我的问题的解决方案,发现有很多开发人员遇到这个问题.我正在使用iOS 6,应用程序仍在生产中,因此它位于沙盒中.
我在Ray Wenderlich教程中使用相同的代码 - CatRace(有太多人写这个问题,但没有人发布解决方案.
有人知道如何解决这个问题吗?