10 Replies
      Latest reply on Apr 2, 2019 4:34 PM by yo_asakura
      meydany Level 1 Level 1 (0 points)

        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 
             } else { 
                  print("Authentication changed: player not authenticated") 
                  authenticated = false 


        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) {
             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.


        Stackoverflow question: http://stackoverflow.com/questions/32940421/game-center-invite-fails-immediately-swift