gkturnbasedmatch

GKTurnBasedMatch detect invitation


I have a view that lists all available matches for a local player (which was registered as the listener). The problem I have is that I want my list to update when the player receives an invitation for a new match.

I tried implementing:

func player(_ player: GKPlayer, didAccept invite: GKInvite) {

}

func player(_ player: GKPlayer, didRequestMatchWithOtherPlayers playersToInvite: [GKPlayer]) {

}

But those methods never get called.

I do get notification of other events, such as turnBasedMatchmakerViewController(_ viewController: GKTurnBasedMatchmakerViewController, didFind match: GKTurnBasedMatch) and player(_ player: GKPlayer, receivedTurnEventFor match: GKTurnBasedMatch, didBecomeActive: Bool)

Also, I do get the banner from Game Center at the top of the screen, and if I tap it, it does register the turn event, but it just won't detect when an invite is received.

Any suggestions?


Solution

  • I wrote a bug complaining that didAcceptInvite never fires. Apple closed the bug saying that was intentional, that didAcceptInvite only applies to real-time matches (even though the documentation doesn't say that).

    I wanted to do the same thing you describe: provide an always current list of matches. Despite the game center notices, I never found an event that I could detect myself.

    In the end, I put a table on a separate view and queried the list of all matches each time the view was shown or the user pulled-to-refresh the table inside the view. I considered using a timer to periodically refresh the list, but never actually went that far.