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
| Parameter | Type | Platform | Required | Description |
|---|---|---|---|---|
ctx | Context | Android | Yes | Application context |
config | VGClientInitConfig / ClientInitConfigObject | All | No | Optional configuration for the client |
VGClientInitConfig / ClientInitConfigObject
The following properties are commonly used for emergency calling initialization:
| Property | Type | Required | Description |
|---|---|---|---|
emergencyPrimaryRegion | string | No | Primary emergency service region URL |
emergencySecondaryRegion | string | No | Secondary emergency service region URL for failover |
loggingLevel | LoggingLevel | No | Logging 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) orVonageClient(combined with voice and emergency) - iOS: Use
VGEmergencyClient(standalone) orVGVonageClient(combined with voice and emergency) - Web: Emergency functionality is available in
VonageClient(combined SDK)
- Android: Use
- 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 (
emergencyPrimaryRegionandemergencySecondaryRegion) can be set to optimize routing and provide failover capabilities
Related Actions
emergencyCall- Make an emergency call