The GKVoiceChatService class allows your application to connect two iOS devices into a voice chat.


class GKVoiceChatService : NSObject


Before you can use voice chat, your application must configure an audio session that allows for both play and recording (kAudioSessionCategory_PlayAndRecord). For more information on audio sessions, see Audio Session Programming Guide.

The voice chat service uses a client implemented by your application to find and connect to other participants. Each participant in the chat is identified by a unique participant identifier string. The client provides a participant identifier for the local user and translates other participant identifiers into connections to other users. The format and mechanism used to translate participant identifiers into network connections is defined by the client. See Game Center Programming Guide for a more complete discussion.

Your application can configure the voice chat service to control the volume level of both local and remote participants and to detect when someone is speaking.

To use the voice chat service, your application retrieves the default service and attaches a client to it, then either connects to another participant or waits for them to start a connection.


Determining Whether Voice Chat Is Available

class func isVoIPAllowed() -> Bool

Returns whether voice chat is allowed to be used on the device.

Getting the Shared Voice Chat Service

class func `default`() -> GKVoiceChatService!

Retrieves the singleton chat service.

Setting the Client

var client: GKVoiceChatClient!

An object that the voice chat service uses to communicate with remote participants.

Establishing a Voice Chat

func startVoiceChat(withParticipantID: String!)

Sends a request to another participant to join the voice chat.

Adjusting Audio Properties

var isMicrophoneMuted: Bool

A Boolean value that determines whether the user’s microphone is muted.

var remoteParticipantVolume: Float

A float that scales the volume of all remote participants.

Monitoring the Audio Level

var isInputMeteringEnabled: Bool

A Boolean value that indicates whether the microphone’s sound level is being monitored.

var inputMeterLevel: Float

The volume, in decibels (db), being received by the microphone.

var isOutputMeteringEnabled: Bool

A Boolean value that indicates whether the voice level of remote participants is monitored.

var outputMeterLevel: Float

The volume, in decibels (db), being received from all other participants.

Ending a Voice Chat

func stopVoiceChat(withParticipantID: String!)

Ends a previously established voice chat.

Methods Called by the Client

func acceptCallID(Int)

Accepts a request from a remote user to establish a voice chat.

func denyCallID(Int)

Rejects a request to establish a voice chat.

func receivedData(Data!, fromParticipantID: String!)

Called by the client to deliver new data received from a remote participant.

func receivedRealTime(Data!, fromParticipantID: String!)

Called by the client to deliver voice data received from a remote participant..


Voice Chat Service Error Domain

The GKVoiceChatService error domain.

enum GKVoiceChatServiceError.Code

Error codes for the GKVoiceChatService error domain.


Inherits From

Conforms To

See Also

Voice Chat

protocol GKVoiceChatClient

The GKVoiceChatClient protocol is implemented to control the behavior of the GKVoiceChatService object. The voice chat client has a number of responsibilities: