Kotlin

ChatClient

Before you can start a chat, the Client SDK needs to authenticate to the Vonage servers. Start by creating a new Kotlin file ChatViewModel.kt.

Create a new class ChatViewModel:

This class will create an instance of ChatClient then create a session using a JWT. Replace ALICE_JWT and BOB_JWT with the JWTs you created earlier.

Button Actions

For the log in buttons to work, you need to add actions to them which will run a function when they are tapped. Update the view code in MainActivity.kt to instantiate a ChatViewModel object and call its login function: