Skip to main content
CLASS

TxClient

The TelnyxRTC client connects your application to the Telnyx backend, enabling you to make outgoing calls and handle incoming calls.

Examples

Connect and login:

Listen TxClient delegate events.

Properties

calls

Keeps track of all the created calls by theirs UUIDs

delegate

Subscribe to TxClient delegate to receive Telnyx SDK events

aiAssistantManager

AI Assistant Manager for handling AI-related functionality

isSpeakerEnabled

isAudioDeviceEnabled

Controls the audio device state when using CallKit integration. This property manages the WebRTC audio session activation and deactivation. When implementing CallKit, you must manually handle the audio session state:
  • Set to true in provider(_:didActivate:) to enable audio
  • Set to false in provider(_:didDeactivate:) to disable audio
Example usage with CallKit:

isRegistered

Client must be registered in order to receive or place calls.

Methods

enableAudioSession(audioSession:)

Enables and configures the audio session for a call. This method sets up the appropriate audio configuration and activates the session.
  • Parameter audioSession: The AVAudioSession instance to configure
  • Important: This method MUST be called from the CXProviderDelegate’s provider(_:didActivate:) callback to properly handle audio routing when using CallKit integration.
Example usage:

Parameters

disableAudioSession(audioSession:)

Disables and resets the audio session. This method cleans up the audio configuration and deactivates the session.
  • Parameter audioSession: The AVAudioSession instance to reset
  • Important: This method MUST be called from the CXProviderDelegate’s provider(_:didDeactivate:) callback to properly clean up audio resources when using CallKit integration.
Example usage:

Parameters

init()

TxClient has to be instantiated.

deinit

Deinitializer to ensure proper cleanup of resources

connect(txConfig:serverConfiguration:)

Connects to the iOS cloglient to the Telnyx signaling server using the desired login credentials.
  • Parameters:
    • txConfig: The desired login credentials. See TxConfig docummentation for more information.
    • serverConfiguration: (Optional) To define a custom signaling server and TURN/ STUN servers. As default we use the internal Telnyx Production servers.
  • Throws: TxConfig parameters errors

Parameters

disconnect()

Disconnects the TxClient from the Telnyx signaling server.

isConnected()

To check if TxClient is connected to Telnyx server.
  • Returns: true if TxClient socket is connected, false otherwise.

answerFromCallkit(answerAction:customHeaders:debug:)

Answers an incoming call from CallKit and manages the active call flow. This method should be called from the CXProviderDelegate’s provider(_:perform:) method when handling a CXAnswerCallAction. It properly integrates with CallKit to answer incoming calls.

Examples:

  • Parameters:
    • answerAction: The CXAnswerCallAction provided by CallKit’s provider delegate.
    • customHeaders: (optional) Custom Headers to be passed over webRTC Messages. Headers should be in the format X-key:Value where X- prefix is required for custom headers. When calling AI Agents, headers with the X- prefix will be mapped to dynamic variables (e.g., X-Account-Number becomes {{account_number}}). Hyphens in header names are converted to underscores in variable names.
    • debug: (optional) Enable debug mode for call quality metrics and WebRTC statistics. When enabled, real-time call quality metrics will be available through the call’s onCallQualityChange callback.

Parameters

endCallFromCallkit(endAction:callId:)

To end and control callKit active and conn

disablePushNotifications()

To disable push notifications for the current user

getSessionId()

Get the current session ID after logging into Telnyx Backend.
  • Returns: The current sessionId. If this value is empty, that means that the client is not connected to Telnyx server.

anonymousLogin(targetId:targetType:targetVersionId:userVariables:reconnection:serverConfiguration:)

Performs an anonymous login to the Telnyx backend for AI assistant connections. This method allows connecting to AI assistants without traditional authentication. If the socket is already connected, the anonymous login message is sent immediately. If not connected, the socket connection process is started, and the anonymous login message is sent once the connection is established.
  • Parameters:
    • targetId: The target ID for the AI assistant
    • targetType: The target type (defaults to “ai_assistant”)
    • targetVersionId: Optional target version ID
    • userVariables: Optional user variables to include in the login
    • reconnection: Whether this is a reconnection attempt (defaults to false)
    • serverConfiguration: Server configuration to use for connection (defaults to TxServerConfiguration())

Parameters

sendRingingAck(callId:)

Send a ringing acknowledgment message for a specific call
  • Parameter callId: The call ID to acknowledge

Parameters

sendAIAssistantMessage(_:)

Send a text message to AI Assistant during active call (mixed-mode communication)
  • Parameter message: The text message to send to AI assistant
  • Returns: True if message was sent successfully, false otherwise

Parameters

sendAIAssistantMessage(_:base64Images:imageFormat:)

Send a text message with multiple Base64 encoded images to AI Assistant during active call
  • Parameters:
    • message: The text message to send to AI assistant
    • base64Images: Optional array of Base64 encoded image data (without data URL prefix)
    • imageFormat: Image format (jpeg, png, etc.). Defaults to “jpeg”
  • Returns: True if message was sent successfully, false otherwise

Parameters