Skip to content

PubNubDevelopers/Chat-SDK-Tutorial-Kotlin

Repository files navigation

Kotlin Chat SDK Tutorial

This application accompanies the Kotlin Chat SDK tutorial. It is not designed to be a standalone demo for the Kotlin Chat SDK, it just illustrates some basic principles.

Please refer to https://www.pubnub.com/tutorials/chat-sdk/ for the tutorial that accompanies this application.

Screenshot

Screenshot

Features included in this application

  • Chat initialization & PubNub Keys
  • Creating a specific user and logging in as that user.
  • Creating a public chat
  • Creating a 1:1 (direct) chat
  • Sending messages
  • Loading historical message (persistence / message history)
  • Typing indicator
  • Message reactions
  • Sent and read receipts

Screenshot

Screenshot

Screenshot

Screenshot

Installation / Getting Started

This application is written with Android Studio Koala but should compile with any recent version of the Android Studio IDE.

To run this project yourself you will need a PubNub Account

Get Your PubNub Keys

  1. You’ll first need to sign up for a PubNub account. Once you sign up, you can get your unique PubNub keys from the PubNub Developer Portal.

  2. Sign in to your PubNub Dashboard.

  3. Click Apps, then Create New App.

  4. Give your app a name, and click Create.

  5. Click your new app to open its settings, then click its keyset.

  6. Enable the Stream Controller feature on your keyset (this should be enabled by default after you created the keyset)

  7. Enable the Message Persistence feature on your keyset and choose a duration

  8. Enable the App Context feature on your keyset.

  9. Leave the File Sharing feature disabled. Although the Chat SDK supports sending files, this demo app does not.

  10. Copy the Publish and Subscribe keys and paste them into your app as specified in the next step.

Building and Running

  1. Clone the repository

  2. Create the file /app/src/main/java/com/pubnub/chatsdk/kotlintutorial/Keys.kt

  3. Populate the file as follows, replacing the placeholder text as appropriate:

package com.pubnub.chatsdk.kotlintutorial
val PUBNUB_PUBLISH_KEY="YOUR_PUBNUB_PUBLISH_KEY"
val PUBNUB_SUBSCRIBE_KEY="YOUR_PUBNUB_SUBSCRIBE_KEY"

Compile and run the application

Using the Application

At the login screen choose a name. This is a free form field and you don't need to register for an account or create a password. Behind the scenes, a PubNub user ID is created based on your chosen name.

Screenshot

Contributing

This repository is not open to feature requests but pull requests are always welcome for bugs.

About

Application to accompany the Kotlin Chat SDK tutorial

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages