iOS Developer Library

Developer

GameKit Framework Reference GKVoiceChatClient Protocol Reference

Options
Deployment Target:

On This Page
Language:

GKVoiceChatClient

Inheritance


Not Applicable

Import Statement


Swift

import GameKit

Objective-C

@import GameKit;

Availability


Available in iOS 3.0 and later.

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

  • Provides a network connection that the voice chat service uses to send and receive configuration data with other participants. If this network connection is shared with other application data, the client must also disambiguate between chat configuration data and application data.

  • Provides a participant ID that identifies the user to remote participants in the chat.

  • Defines how a remote user’s participant ID translates into a network connection to that user.

  • Accepts or rejects requests from remote participants to join the voice chat.

  • Returns a string that uniquely identifies the local user. (required)

    Declaration

    Swift

    func participantID() -> String!

    Objective-C

    - (NSString *)participantID

    Return Value

    A string that can be used by other participants to connect to the local user.

    Discussion

    The client decides the format and meaning of the participant identifier. For more information, see the Game Center Programming Guide.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 3.0 and later.

  • A request for the client to send data to a participant. (required)

    Declaration

    Swift

    func voiceChatService(_ voiceChatService: GKVoiceChatService!, sendData data: NSData!, toParticipantID participantID: String!)

    Objective-C

    - (void)voiceChatService:(GKVoiceChatService *)voiceChatService sendData:(NSData *)data toParticipantID:(NSString *)participantID

    Parameters

    voiceChatService

    The service that requested the transmission.

    data

    The data to send.

    participantID

    A string that uniquely identifies the participant to send the data to.

    Discussion

    An implementation of this method must reliably transmit the data to the participant identified by participantID. When the client on the other end receives the data, it should forward it to the voice chat service by calling the service’s receivedData:fromParticipantID: method.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 3.0 and later.

  • Asks the client to send data to a participant that must get there quickly.

    Declaration

    Swift

    optional func voiceChatService(_ voiceChatService: GKVoiceChatService!, sendRealTimeData data: NSData!, toParticipantID participantID: String!)

    Objective-C

    - (void)voiceChatService:(GKVoiceChatService *)voiceChatService sendRealTimeData:(NSData *)data toParticipantID:(NSString *)participantID

    Parameters

    voiceChatService

    The service that requested the transmission.

    data

    The data to send.

    participantID

    A string that uniquely identifies the participant to send the data to.

    Discussion

    An implementation of this method maps the participantID string to a known participant and transmits the data to them. Data transmitted by this method can be sent unreliably. When the client on the other end receives this data, it should forward it to the voice chat service by calling the service’s receivedRealTimeData:fromParticipantID: method.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 3.0 and later.

  • Asks the client to accept or reject an invitation from a remote participant.

    Declaration

    Swift

    optional func voiceChatService(_ voiceChatService: GKVoiceChatService!, didReceiveInvitationFromParticipantID participantID: String!, callID callID: Int)

    Objective-C

    - (void)voiceChatService:(GKVoiceChatService *)voiceChatService didReceiveInvitationFromParticipantID:(NSString *)participantID callID:(NSInteger)callID

    Parameters

    voiceChatService

    The service that received the request.

    participantID

    A string that uniquely identifies the other user.

    callID

    An integer that uniquely identifies the request.

    Discussion

    If this method is not implemented by the client, the voice chat service automatically accept requests from other participants.

    This method should call the service’s acceptCallID:error: method if it wants to accept the request or the denyCallID: to reject it.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 3.0 and later.

  • Received by the client when a voice chat with another participant is established.

    Declaration

    Swift

    optional func voiceChatService(_ voiceChatService: GKVoiceChatService!, didStartWithParticipantID participantID: String!)

    Objective-C

    - (void)voiceChatService:(GKVoiceChatService *)voiceChatService didStartWithParticipantID:(NSString *)participantID

    Parameters

    voiceChatService

    The voice chat service that initiated the connection.

    participantID

    A string that uniquely identifies the other user.

    Discussion

    Your client can use this method to update the user interface to show that a connection has been established.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 3.0 and later.

  • Received by the client when an attempt to establish a voice chat with another participant failed.

    Declaration

    Swift

    optional func voiceChatService(_ voiceChatService: GKVoiceChatService!, didNotStartWithParticipantID participantID: String!, error error: NSError!)

    Objective-C

    - (void)voiceChatService:(GKVoiceChatService *)voiceChatService didNotStartWithParticipantID:(NSString *)participantID error:(NSError *)error

    Parameters

    voiceChatService

    The voice chat service that was establishing the connection.

    participantID

    A string that uniquely identifies the other user.

    error

    The error that prevented the voice chat from being established.

    Discussion

    Your application can implement this method to notify the user that an error occurred when establishing a connection.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 3.0 and later.

  • Received by the client when a previously established voice chat has ended.

    Declaration

    Swift

    optional func voiceChatService(_ voiceChatService: GKVoiceChatService!, didStopWithParticipantID participantID: String!, error error: NSError!)

    Objective-C

    - (void)voiceChatService:(GKVoiceChatService *)voiceChatService didStopWithParticipantID:(NSString *)participantID error:(NSError *)error

    Parameters

    voiceChatService

    The voice chat that maintained the connection.

    participantID

    A string that uniquely identifies the user who disconnected.

    error

    The error that caused the chat to end.

    Discussion

    Your application can implement this method to notify the user that an established voice connection has ended. This may occur when another participant ends the chat or if the network connection was lost.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in iOS 3.0 and later.