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.