As the apple guidelines said; I've implemented the GKLocalPlayerListener
protocol in my game center class and add the local player as listener as soon as he's authenticated:
func authenticationChanged() {
if (GKLocalPlayer.localPlayer().authenticated && !self.userAutenticated) {
println("Authentication changed: player authenticated.")
userAutenticated = true
GKLocalPlayer.localPlayer().unregisterAllListeners()
GKLocalPlayer.localPlayer().registerListener(self)
} else if (GKLocalPlayer.localPlayer().authenticated && self.userAutenticated) {
println("Authentication changed: player not authenticated.")
userAutenticated = false
}
}
Protocol implementation:
// MARK: - GKLocalPlayerListener
func player(player: GKPlayer!, didAcceptInvite invite: GKInvite!) {
println("Did accept invite")
}
func player(player: GKPlayer!, didRequestMatchWithRecipients recipientPlayers: [AnyObject]!) {
println("Did request matchmaking")
}
None of this 2 methods it's called when I try to invite a friend and I also didn't receive any kind of notifications. I've tried to test the game in release mode but I've got the same result. I must say the the normal matchmaking works correctly, I'm able to find player to play with without any problems.
EDIT:
If i test test it from 2 devices, the notification will be received but if i tap on the notification, the app will be open and no delegate will be called. If i close the app and restart it again, then the GKLocalPlayerListener
it's called.
What's wrong??
unregisterAllListeners
if authentication is changed to false. – Meshwork