2

I am making a turnbased game using the gamecenter api. I wanted to make a one press button to rematch players so they don't have to go through the gamecenter view controllers and re invite the same player. In this question iOS Game Kit Turn Based Match Programatic Rematch the asker notes later on that ios 6.0 makes this really easy using rematchWithCompletionHandler. I have tried to use this in my game and have only gotten unkown selector errors or NSErrors saying that the match I am trying to create is not possible.

[currentMatch rematchWithCompletionHandler:^(GKTurnBasedMatch *match, NSError *error)
         {
             if (error) {
                 NSLog(@"%@", error);
             }

             else
             {
                 currentMatch = match;
                 currentMatch.message = @"Rematch";
             }

         }];

Is there some stage that the match has to be in before calling rematch? or something I am missing?

Community
  • 1
  • 1
mrobertson
  • 21
  • 1

2 Answers2

0

rematchWithCompletionHandler appears to only work when a match has been correctly ended by all players involved with the match.

Jay Haase
  • 1,979
  • 1
  • 16
  • 36
  • With 'correctly ended' do you mean that each peer has to have called GkMatch disconnect() ? – Bram Mar 13 '13 at 04:23
  • @Bram, this question was talking about GKTurnBasedMatch. GKTurnBasedMatch does not have a disconnect method. Here are some ways to end a turn based match: participantQuitInTurnWithOutcome:nextParticipants:turnTimeout:matchData:completionHandler, participantQuitOutOfTurnWithOutcome:withCompletionHandler, endMatchInTurnWithMatchData:completionHandler – Jay Haase Mar 13 '13 at 14:35
  • 1
    I have a real time match, and when I request a rematch, I get a callback without error, but expectedPlayers is 1, not 0. – Bram Mar 13 '13 at 17:47
  • Sorry, I don't currently know about real time matches. Maybe you could make a new question about it? I think you would have a better chance of getting an answer. – Jay Haase Mar 14 '13 at 03:46
  • @Bram I know it's been over ten years haha, but were you able to figure this out? – eschos24 Jun 12 '23 at 05:19
0

It only works for me when the two players are Game Center friends.

colinta
  • 3,536
  • 1
  • 28
  • 18