Skip to content

Client Initialization

Initialize the Vonage Client to access voice and emergency calling features. The combined SDK (VonageClient) provides all capabilities in a single client instance.

Chat API Deprecation

The Chat API is deprecated and will be removed in a future release. New applications should not use chat features. Existing applications should plan migration away from the Chat API.

Signature

VonageClient(
  ctx: Context,
  config: VGClientInitConfig = VGClientInitConfig()
)

Parameters

ParameterTypePlatformRequiredDescription
ctxContextAndroidYesApplication context
configVGClientInitConfig / ClientInitConfigObjectAllNoOptional configuration for the client

VGClientInitConfig / ClientInitConfigObject

The following properties are commonly used for emergency calling initialization:

PropertyTypeRequiredDescription
emergencyPrimaryRegionstringNoPrimary emergency service region URL
emergencySecondaryRegionstringNoSecondary emergency service region URL for failover
loggingLevelLoggingLevelNoLogging level for the client

For additional configuration options (region, API URLs, WebSocket settings, etc.), see the Configuring the Client After Initialization section below.

Return Type

Returns an instance of VonageClient (Android/Web) or VGVonageClient (iOS) with emergency, voice, and chat capabilities.

Usage Example

Basic Initialization


 val client = VonageClient(ctx)

Initialization with Configuration

You can initialize the client with custom configuration, including emergency regions and logging level:


 val config = VGClientInitConfig().apply {
     emergencyPrimaryRegion = "https://api-us-3.vonage.com"
     emergencySecondaryRegion = "https://api-us-4.vonage.com"
     loggingLevel = LoggingLevel.Info
 }
 val client = VonageClient(ctx, config)

Configuring the Client After Initialization

After initialization, you can configure the client with additional settings such as region, API URLs, and other runtime options:


 val config = VGClientConfig(VGConfigRegion.EU)
 config.apiUrl = "https://api.example.com"
 config.websocketUrl = "https://ws.example.com"
 config.enableWebsocketInvites = true
 config.rtcStatsTelemetry = true
 config.autoReconnectMedia = false
 config.enableNoiseSuppression = true
 client.setConfig(config)

Notes

  • Client Options:
    • Android: Use EmergencyClient (standalone) or VonageClient (combined with voice and emergency)
    • iOS: Use VGEmergencyClient (standalone) or VGVonageClient (combined with voice and emergency)
    • Web: Emergency functionality is available in VonageClient (combined SDK)
  • Standalone vs Combined:
    • Use the standalone Emergency Client if you only need emergency calling features
    • Use the Combined Client (VonageClient) if you need emergency along with voice features
    • The combined client also includes the deprecated Chat API for backwards compatibility
  • The client manages the lifecycle of emergency call connections
  • Configuration is optional and uses sensible defaults if not provided
  • Emergency regions (emergencyPrimaryRegion and emergencySecondaryRegion) can be set to optimize routing and provide failover capabilities

Built with VitePress.