This tutorial will walk you through setting up a basic sample app created using the PubNub Kotlin Chat SDK, explaining the architecture behind the app and how the code works. The devrel team has developed the Kotlin Chat SDK sample that will be used for this tutorial, which can be found at https://github.com/PubNubDevelopers/Chat-SDK-Tutorial-Kotlin and is released under MIT. The sample is designed for illustrative purposes only and has minimal error handling.
The Kotlin Chat SDK is UI and framework-agnostic, allowing you complete control over how your application looks and how it is architected. The sample application has been written with Jetpack Compose with some custom UI.
Make sure you have the following installed on your computer:
In a terminal or command window, navigate to an empty folder. Enter the following command to clone the repository.
1
git clone https://github.com/PubNubDevelopers/Chat-SDK-Tutorial-Kotlin.git
This step is optional but will ensure that the version of the repository you are using matches the version used to create this tutorial.
1
git checkout 1f078a92b2a1f5607e2d7b50775ef6f5488d5b4e
Open the Chat-SDK-Tutorial-Kotlin
folder in Android Studio. This should download the required dependencies using gradle. We strive to maintain up-to-date instructions for all our tutorials, but if you experience build issues - especially with newer versions of Android Studio, please contact our DevRel team at devrel@pubnub.com.
Open the following file:
/app/src/main/java/com/pubnub/chatsdk/kotlintutorial/Keys.kt
The file currently contains placeholders for your PubNub publish and subscribe keys:
1 2 3 4 5
package com.pubnub.chatsdk.kotlintutorial // REPLACE THESE WITH YOUR PUB / SUB KEYS val PUBNUB_PUBLISH_KEY="PUBLISH_KEY" val PUBNUB_SUBSCRIBE_KEY="SUBSCRIBE_KEY"
The next step is to generate your own publish and subscribe keys to replace these placeholders.