Occasionally, but not rarely, the findMatchForRequest:withCompletionHandler:
returns with error 13 or GKErrorMatchRequestInvalid
:
"The requested operation could not be completed because the match request is invalid."
The documentation only says:
GKErrorMatchRequestInvalid
The match request’s properties are impossible to fulfill. For example, the minimum number of players cannot be larger than the maximum number of players. Available in iOS 4.0 and later.
I think that GKErrorMatchRequestInvalid
never occurs on 1st try, that is, when directly after launching from Xcode, but only on 2nd/3rd/... tries. Happens on either the device or the simulator. So I assume that I am doing something wrong, but what? Is there an exhaustive list of conditions under which GKMatchRequest
is invalid?
Tried to recover from GKErrorMatchRequestInvalid
by recalling findMatchForRequest:
, but never succeed: once I get an 'invalid' match
, then all further findMatchForRequest:
calls also return with an 'invalid' match
. Trying to remedy this by using both [[GKMatchmaker sharedMatchmaker] cancel]
and [[GKMatchmaker sharedMatchmaker] finishMatchmakingForMatch:
... obviously, I don't even have a valid match
to finishMatchmakingFor:
.
The matchmaking happens in a singleton (if that matters). Here's the relevant code:
GKMatchRequest *request = [GKMatchRequest new];
request.minPlayers = 3;
request.maxPlayers = 4;
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error)
{
if (error)
{
if (error.code == 503 ||
error.code == GKErrorMatchRequestInvalid ||
error.code == GKErrorNotAuthenticated ||
error.code == GKErrorCommunicationsFailure ||
error.code == GKErrorUnknown ||
error.code == GKErrorInvalidPlayer ||
error.code == GKErrorInvalidParameter ||
error.code == GKErrorAuthenticationInProgress)
{
[self.delegate restartMatchmaking];
}
}
else if (match)
{
// happy-path
}
}];