A voice channel that allows a set of players in a match to speak with each other.
- iOS 4.1+
- macOS 10.8+
- tvOS 9.0+
In an iOS game, before you can use voice chat, your game must configure an audio session that allows for both play and recording (
k). For more information on audio sessions, see Audio Session Programming Guide.
You use the
GKMatch object to create a voice chat channel by calling its
voice method, passing in a string that identifies the name of the channel you want to join. The name is never displayed by GameKit, and you are free to name the channels however you like. You can create multiple channels for the same match. For example, if the match has multiple teams, you might create a separate channel for each team, and an additional channel that holds all of the players in the match.
To connect a player to a channel, call the voice chat object’s
start() method. After a channel is started, it receives voice data from other players already in the channel. To allow the player to speak in a channel, set the voice chat object’s
is property to
true. A player can listen to multiple channels simultaneously but may only speak on one channel at any given time.
If there is insufficient bandwidth over wi-fi to maintain a voice chat, GameKit may disconnect individual players from the channel or disband the channel entirely.