1

There's a [similar question from '12]1, but it's turn-by-turn game (may or may not make difference), it was not resolved, and there've possibly been Game Center/GameKit changes since them.

Simple case is two players on iOS, and both tap a button that executes this code (currentMatch is a class property GKMatch?):

    if let match = currentMatch {
        print("create rematch completion handler")
        match.rematch(completionHandler: {(newMatch, error) in
            print("execute rematch completion handler")
            if let error = error {
                print(error)
            }
            if let newMatch = newMatch {
                print("rematch completed \(newMatch.players.count)")
                self.currentMatch = newMatch
            }
        })
    }

The log returns:

create rematch completion handler
match did change state ‎“‪Player2” 2
disconnected from ‎“‪Player2”
execute rematch completion handler
rematch completed 0

Thus, GameKit is disconnecting the players on its own, executing the completion handler, and seemingly creating a new match with 0 players.

Any suggestions on what to do differently to have the rematch with the original players? Has anyone ever had this work? Thanks.

JKaz
  • 765
  • 6
  • 18
  • Were you able to figure this out? I used to have this working, but I was trying to update my code and I appear to have broken the rematch functionality somehow and nothing I try is working at all. – eschos24 Jun 12 '23 at 05:20

0 Answers0