1

I'm creating a turn-based game using gamecenter. It is a one to one game so every game has two participants.

When a game is finished, a gameover screen appears and either of the participants can press "rematch" to start a new game with the same opponent.

The code I use when the button is pressed is (simplified) this:

let request = GKMatchRequest()
        request.maxPlayers = 2
        request.minPlayers = 2
        request.recipients = [opponent]

GKTurnBasedMatch.findMatchForRequest(request, withCompletionHandler: {
            match, error in
            if error != nil {
                println("FIND MATCH REQUEST ERROR:\(error.localizedDescription)")
            } else {
                println("Match Found")}})

Now, my question is this. When I rematch a game where the opponent is a friend of mine in gamecenter everything seems to work fine. However, if I rematch a game where the opponent is not a friend of mine in gamecenter I get the following error:

The requested operation could not be completed because the player is invalid.

However, when I print the opponent player (GKPlayer) I get the following (which seems to be fine and not invalid as the error suggests):

(playerID:g:58D9E388A2CD0DEFC795DC9035E7D22A alias:TestBoomar_1 name:‎“‪TestBoomar_1‬” status:(null))

So, my question is this: Do GKMatchRequest recipients have to be the players friends in order for those recipients to be valid? Shouldn't recipients be able to be any players in Gamecenter, not dependent on whether they are friends of the game creator?

Any input is appreciated, Thanks!

μ4ρκ05
  • 585
  • 2
  • 5
  • 16
  • It seems you're not alone (http://stackoverflow.com/questions/30922003/ios-issue-with-rematchwithcompletionhandler-in-sandbox). Have you tried opening a bug with Apple? – Thunk Jun 29 '15 at 21:22

0 Answers0