Class: TelnyxVoipClient
Defined in: telnyx-voip-client.ts:30 The main public interface for the react-voice-commons module. This class serves as the Façade for the entire module, providing a simplified API that completely hides the underlying complexity. It is the sole entry point for developers using the react-voice-commons package. The TelnyxVoipClient is designed to be state-management agnostic, exposing all observable state via RxJS streams. This allows developers to integrate it into their chosen state management solution naturally.Constructors
Constructor
new TelnyxVoipClient(Defined in: telnyx-voip-client.ts:41 Creates a new TelnyxVoipClient instance.options):TelnyxVoipClient
Parameters
options
TelnyxVoipClientOptions = {}
Configuration options for the client
Returns
TelnyxVoipClient
Accessors
connectionState$
Get Signature
get connectionState$():Defined in: telnyx-voip-client.ts:74 Stream of connection state changes. Emits the current status of the connection to the Telnyx backend. Values include connecting, connected, disconnected, and error states. Listen to this to show connection indicators in your UI.Observable<TelnyxConnectionState>
Returns
Observable<TelnyxConnectionState>
calls$
Get Signature
get calls$():Defined in: telnyx-voip-client.ts:85 Stream of all current calls. Emits a list of all current Call objects. Use this for applications that need to support multiple simultaneous calls (e.g., call waiting, conference calls).Observable<Call>
Returns
Observable<Call>
activeCall$
Get Signature
get activeCall$():Defined in: telnyx-voip-client.ts:96 Stream of the currently active call. A convenience stream that emits the currently active Call object. It emits null when no call is in progress. Ideal for applications that only handle a single call at a time.Observable<Call>
Returns
Observable<Call>
currentConnectionState
Get Signature
get currentConnectionState(): TelnyxConnectionState
Defined in: telnyx-voip-client.ts:105
Current connection state (synchronous access).
Returns
TelnyxConnectionState
currentCalls
Get Signature
get currentCalls(): Call
Defined in: telnyx-voip-client.ts:112
Current list of calls (synchronous access).
Returns
Call
currentActiveCall
Get Signature
get currentActiveCall(): Call
Defined in: telnyx-voip-client.ts:119
Current active call (synchronous access).
Returns
Call
sessionId
Get Signature
get sessionId(): string
Defined in: telnyx-voip-client.ts:126
Current session ID (UUID) for this connection.
Returns
string
options
Get Signature
get options():Defined in: telnyx-voip-client.ts:133 Configuration options for this client instance.Required<TelnyxVoipClientOptions>
Returns
Required<TelnyxVoipClientOptions>
Methods
login()
login(Defined in: telnyx-voip-client.ts:148 Connects to the Telnyx platform using credential authentication.config):Promise<void>
Parameters
config
CredentialConfig
The credential configuration containing SIP username and password
Returns
Promise<void>
A Promise that completes when the connection attempt is initiated
Listen to connectionState$ to monitor the actual connection status.
Credentials are automatically stored for future reconnection.
loginWithToken()
loginWithToken(Defined in: telnyx-voip-client.ts:175 Connects to the Telnyx platform using token authentication.config):Promise<void>
Parameters
config
TokenConfig
The token configuration containing the authentication token
Returns
Promise<void>
A Promise that completes when the connection attempt is initiated
Listen to connectionState$ to monitor the actual connection status.
Token is automatically stored for future reconnection.
logout()
logout():Defined in: telnyx-voip-client.ts:199 Disconnects from the Telnyx platform. This method terminates the connection, ends any active calls, and cleans up all related resources.Promise<void>
Returns
Promise<void>
loginFromStoredConfig()
loginFromStoredConfig():Defined in: telnyx-voip-client.ts:219 Attempts to reconnect using previously stored configuration. This method is used for auto-reconnection scenarios where the app comes back to the foreground and needs to restore the connection.Promise<boolean>
Returns
Promise<boolean>
Promise<boolean> - true if reconnection was successful, false otherwise
newCall()
newCall(Defined in: telnyx-voip-client.ts:296 Initiates a new outgoing call.destination,callerName?,callerNumber?,customHeaders?):Promise<Call>
Parameters
destination
string
The destination number or SIP URI to call
callerName?
string
Optional caller name to display
callerNumber?
string
Optional caller ID number
customHeaders?
Record<string, string>
Optional custom headers to include with the call
Returns
Promise<Call>
A Promise that completes with the Call object once the invitation has been sent
The call’s state can be monitored through the returned Call object’s streams.
handlePushNotification()
handlePushNotification(Defined in: telnyx-voip-client.ts:335 Handle push notification payload. This is the unified entry point for all push notifications. It intelligently determines whether to show a new incoming call UI or to process an already actioned (accepted/declined) call upon app launch.payload):Promise<void>
Parameters
payload
Record<string, any>
The push notification payload
Returns
Promise<void>
disablePushNotifications()
disablePushNotifications(): void
Defined in: telnyx-voip-client.ts:371
Disables push notifications for the current session.
This method sends a request to the Telnyx backend to disable push
notifications for the current registered device/session.
Returns
void
setCallConnecting()
setCallConnecting(Defined in: telnyx-voip-client.ts:388callId):void
Internal
Set a call to connecting state (used for push notification calls when answered via CallKit)
Parameters
callId
string
The ID of the call to set to connecting state
Returns
void
findCallByTelnyxCall()
findCallByTelnyxCall(Defined in: telnyx-voip-client.ts:397telnyxCall):Call
Internal
Find a call by its underlying Telnyx call object
Parameters
telnyxCall
any
The Telnyx call object to find
Returns
Call
queueAnswerFromCallKit()
queueAnswerFromCallKit(Defined in: telnyx-voip-client.ts:406 Queue an answer action for when the call invite arrives (for CallKit integration) This should be called when the user answers from CallKit before the socket connection is establishedcustomHeaders):void
Parameters
customHeaders
Record<string, string> = {}
Optional custom headers to include with the answer
Returns
void
queueEndFromCallKit()
queueEndFromCallKit(): void
Defined in: telnyx-voip-client.ts:427
Queue an end action for when the call invite arrives (for CallKit integration)
This should be called when the user ends from CallKit before the socket connection is established
Returns
void
dispose()
dispose(): void
Defined in: telnyx-voip-client.ts:453
Dispose of the client and clean up all resources.
After calling this method, the client instance should not be used anymore.
This is particularly important for background clients that should be
disposed after handling push notifications.
Returns
void