Skip to content

Migration Guide

There is generally a 1-to-1 mapping functionality-wise between the VonageClientSDK and its predecessor NexmoClient. As a result, migration is generally straightforward. Below is a set of recommended migration paths for existing NexmoClient codebases.

Client Instantiation

The main difference for native platforms - the vonage client is no longer a singleton!

// NexmoSDK
client = NexmoClient.Builder().build(this)

// VonageSDK
client = VoiceClient(this)
client.setConfig(ClientConfig(ClientConfigRegion.US))

Session Management

Client connectivity callbacks have been simplified to make connectivity states more distinct. Initial Connection Result is reported in createSession callback. Future reconnection attempts now have their own listener/delegate methods (onReconnecting, onReconnection, onSessionError) to report results.

// NexmoSDK
client.login(token)

client.setConnectionListener { connectionStatus, _ ->
    when (connectionStatus) {
        ConnectionStatus.CONNECTED -> // #1
        ConnectionStatus.DISCONNECTED -> // #2 
        ConnectionStatus.CONNECTING -> // #3
        ConnectionStatus.UNKNOWN -> // #4
    }
}


// VonageSDK
client.createSession(token) { err, sessionId ->
    when(err) {
        null ->  // #1
        else ->  // #4 + #2 
    }
}
// #3 - implicit whilst you wait for callback 

client.setSessionErrorListener { err ->
    // #2 old style 'reason' will be listener error param
}

client.setReconnectingListener {
    // #3 
}

client.setReconnectionListener {
    // #1 
}

Calls

  • Server calls are the only type of calls a VonageClient is able to make, the previous inApp calls have been deprecated. This means a NCCO webhook is now mandatory for all call flows.
  • ServerCall() params have changed, we have consolidated the previous to and context field into one. For backwards compatibility with existing NCCO webhooks, you can specify to as part of the context object, which will be forwarded to your webhook as before. Otherwise, utilise the context param to send custom data to your answer_url webhook.
// NexmoSDK
client.serverCall("PHONE_NUMBER", null, object : NexmoRequestListener<NexmoCall> {
    override fun onSuccess(call: NexmoCall?) {
        activeCall = call
    }

    override fun onError(apiError: NexmoApiError) {
        //..
    }
})

// VonageSDK
client.serverCall(mapOf("to" to "PHONE_NUMBER")) { err, voiceCall ->
    when(err) {
        null -> {
            activeCall = voiceCall
        }
        else -> //..
    }
}

Built with VitePress.