Game Center invite fails immediately
Asked Answered
P

1

5

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.

Pancreatin answered 5/10, 2015 at 2:19 Comment(4)
I encountered the same issue. Did you find a solution?Stylize
Did you find a solution?Gschu
Nope, sorry. We just ended up working our way around it.Pancreatin
I have my own question on the same topic over here https://mcmap.net/q/1848518/-getting-gamecenter-invite-friend-to-work-ios9/1396265 but I also have no solution so far.Elyse
S
0

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!

Saum answered 25/4, 2016 at 0:33 Comment(2)
Thanks Ben, but what version string do you refer to? The one in xcode in General/Identity?Pale
That is correct. It's also accessible in info.plist with the key "Bundle versions string, short"Saum

© 2022 - 2024 — McMap. All rights reserved.