问题
I create a turn-based match and proceed to invite a single opponent as follows:
GPGMultiplayerConfig *config = [[GPGMultiplayerConfig alloc] init];
// We will automatically match with one other player
config.invitedPlayerIds = @[self.opponent.googlePlayID];
config.minAutoMatchingPlayers = 0;
config.maxAutoMatchingPlayers = 0;
[GPGTurnBasedMatch
createMatchWithConfig:config
completionHandler:^(GPGTurnBasedMatch *match, NSError *error) {
if (error) {
completion(NO);
return;
}
}];
After this device places the first move and passes the next turn to my opponent device, my opponent device receives the push notification to join the match. I respond by joining. At this point my self.match.userMatchStatus
for this invited device is invited
:
[self.match joinWithCompletionHandler:^(NSError *error) {
if (error) {
completion(NO);
return;
}
}];
This doesn't give an error. Upon calling self.match.isMyTurn
, I get back YES
. A call to self.match.userMatchStatus
gives the status of invited
; not joined
. The documentation (which is incredibly poor, by the way) states that this joinWithCompletionHandler:
method:
Joins a turn-based match that the player has been invited to.
Even when adding a dispatch time delay in of 3 seconds after this, to give it a chance, I find that it's still set to invited
. Calling further methods, such as takeTurnWithNextParticipantId:data:results:completionHandler:
, fails with an entirely undocumented error:
Error Domain=com.google.GooglePlayGames Code=3 "The operation couldn’t be completed. (com.google.GooglePlayGames error 3.)"
Here's a link to Google's documentation:
https://developers.google.com/games/services/ios/api/interface_g_p_g_turn_based_match
回答1:
I guess you are passing the player id instead of participant id to takeTurnWithNextParticipantId. The error code 3 (and http response code 400) means that something in passed parameters is invalid, in my case it was the participant id which i had set wrong.
来源:https://stackoverflow.com/questions/24749945/google-play-games-not-allowing-user-to-join-turn-based-match