Kotlin

Fetch the Conversation

Inside MainActivity class add the conversation property:

private var conversation: NexmoConversation? = null

Update body of the getConversation() method:

private fun getConversation() {
    client.getConversation(CONVERSATION_ID, object : NexmoRequestListener<NexmoConversation?> {
        override fun onSuccess(conversation: NexmoConversation?) {
            this@MainActivity.conversation = conversation
        }

        override fun onError(apiError: NexmoApiError) {
            conversation = null
            Toast.makeText(this@MainActivity, "Error: Unable to load conversation", Toast.LENGTH_SHORT)
        }
    })
}

Please make sure to replace CONVERSATION_ID with the conversation id you created during a previous step.

The above method loads the conversation using client.getConversation and then it loads all events from the conversation.

Note: Conversation id is retrieved from Config.CONVERSATION_ID provided in the previous step.