My game was working fine before iOS 10. Now, everyone with iOS 10 can't invite and play with who they want.
When a user says they want to play multiplayer, I create a GKMatchRequest
like this:
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 4;
request.defaultNumberOfPlayers = 2;
I use a GKTurnBasedMatchmakerViewController
to handle the invitation, etc. The user sees an interface that would let them change the number of players in the match and invite players. Let's say that they only want 2 players, so they leave that and they want to play with their friend. So, they use the interface to send an invite to their friend. The result, is that didFindMatch
is called on my delegate with a GKMatch
that has 4 participants. It should only have 2! The first participant is the local player and the other 3 have the status "Matching". So, their friend isn't even in the list. Does anyone have any suggestions for fixing this? This same code works fine in versions of iOS before iOS 10.
It appears that with IOS10, the defaultNumberOfPlayers isn't being honored.
Keep in mind that GKTurnBasedMatch
has three types of players in a given match:
- The Originator who creates the match
- Players that were specifically invited into the match
- Players that automatch into the match
If you look at the player status for all 4 players in the match (using your example), I suspect you will see the following results
- Active (the originator)
- Invited (the 1 person you invited)
- Matching
- Matching
If so, that would indicate that defaultNumberOfPlayers
was ignored, and the match was created with a max of 4 players (1 originator, 1 invitee and 2 automatch slots).
The workaround seems to be to set the maxNumberOfPlayers
to the desired cap, in this case, 2, when you create the match.
来源:https://stackoverflow.com/questions/41916413/turn-based-matchmaking-not-working-in-ios-10