I have implemented a custom matchmaker as a direct drop-in replacement to GKMatchmakerViewController, shown only when running in iOS6+. It is working perfectly, but there is one part of the UI in GKMatchmakerViewController that I can't seem to figure out.
When initiating a 2-player (request.minPlayers = 2, request.maxPlayers = 2) auto-match, GKMatchmakerViewController is able to update its UI with the display name and photo of the player that was found before they have changed to a connected state.
I use the following code to initiate an auto-match. A connection is made and the game starts and everything's fine.
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:matchRequest withCompletionHandler:^(GKMatch *match, NSError *error) {
if (error != nil) {
// ...the error handling code...
} else if (match != nil) {
NSLog(@"An auto-match has been found: %@", match);
if (match.expectedPlayerCount == 0) {
[[GKMatchmaker sharedMatchmaker] finishMatchmakingForMatch:match];
} else {
NSLog(@"player IDs: %@", match.playerIDs);
}
}
}];
However, I'm not able to get the playerID until they have changed to GKPlayerStateConnected via:
- (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state;
When the match is found, that player is in GKPlayerStateUnknown. However, the match NSLog() in the code shows the playerID (it is definitely NOT the localPlayer's ID; the real number has been redacted):
An auto-match has been found: <GKMatch 0x210b2c90 expected count: 1 seqnum: 0
G:1234567890:unknown
reinvitedPlayers:(
)>
The playerIDs array for the match (the second NSLog()) is empty as soon as the match is created, which makes sense because no connections have officially been made yet:
player IDs: (
)
I finally get to the questions (thank you for your patience):
1a) Where is the ID of the player in the unknown state coming from?
1b) It's in the match obviously but where exactly is it being stored? The only thing I see playerID-related is the array which is empty.
2) Is there some other (legal) way to obtain that playerID? i.e. before they change to a connected state