GKMatchRequest
An object that encapsulates the parameters to create a real-time or turn-based match.
Declaration
class GKMatchRequestMentioned in
- Finding multiple players for a game
- Finding players using matchmaking rules
- Finding players for custom server-based games
- Starting turn-based matches and passing turns between players
- Assigning players to teams using rules
- Finding players with similar skill levels
- Troubleshooting matchmaking rules using metrics
Overview
To request a match, set the properties of the match request, such as the number of players, the invitation message, and whether to use automatch to fill the player slots. You’re required to set the minimum and maximum number of players allowed in the match. Then, pass the match request to the appropriate class, depending on the type of game and whether you implement your own user interface.
To use the matchmaking user interface that GameKit provides, pass the match request to the GKMatchmakerViewController class for real-time games, or the GKTurnBasedMatchmakerViewController class for turn-based games. GameKit sends messages to the delegates of these classes when players receive and accept invitations to the match.
If you implement your own interface for finding players, pass the match request to the GKMatchmaker class for real-time games, or the GKTurnBasedMatch class for turn-based games. If the player selects the other players to invite in your interface, set the recipients, the inviteMessage, and the recipientResponseHandler properties before creating the match.
Matchmaking using rules
You can refine the match results and reduce player wait times by configuring matchmaking before you present an interface. You can either find players using matchmaking rules you set up on the server, or find players from a subset of players you specify in the game.
To use matchmaking rules, set the queueName property to the queue name that you configure in App Store Connect. Optionally, set properties and recipientProperties to game-specific criteria. Players in the recipientProperties property need to also be in the recipients property — that is, be a recipient of an invitation. When using matchmaking rules, Game Center ignores the subset that you specify using the playerGroup and playerAttributes properties.
If you set the request’s minPlayers and maxPlayers properties, use values that are in the rule set’s player range. Otherwise, the default values for these properties are the rule set’s minPlayers and maxPlayers fields (see Create a rule set).
If you don’t use matchmaking rules, you can restrict finding players to a subset of players. Set the queueName property to nil, and set the playerGroup and playerAttributes properties to specify the subset. Then matchmaking ignores the rules-based properties and recipientProperties properties.
For more information, see Finding players using matchmaking rules.