Game Center invite fails immediately

≡放荡痞女 提交于 2019-12-01 18:02:13

问题


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:

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)
}

These two pieces of code are all in the same class that conform to the GKMatchmakerViewControllerDelegate, GKGameCenterControllerDelegate, GKMatchDelegate, GKLocalPlayerListener delegates and protocols.


回答1:


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!



来源:https://stackoverflow.com/questions/32940421/game-center-invite-fails-immediately

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!