[go: up one dir, main page]

Skip to content

PubNubDevelopers/GettingStarted-Kotlin-SDK-Tutorial

Repository files navigation

Tutorial: Get Started Developing a Chat app with the Kotlin SDK

Simple chat app to demonstrate the basic principles of creating a chat app with PubNub. This app is written in Kotlin, targeting Android and uses the JetPack Compose library for the UI

PubNub allows you to create chat apps from scratch or add them to your existing applications. You can focus on creating the best user experience while PubNub takes care of scalability, reliability, security, and global legislative compliance.

Create 1:1 private chat rooms, group chats, or mega chats for large scale events, for a variety of use cases.

For the sake of simplicity, this application will only focus on a single 'group chat' room

Screenshot

Demo

This application is not available on the Play Store but can be built and run locally in an emulator (or multiple emulators to simulate chat between multiple participants)

Features

  • Publish and Subscribe for messages with the PubNub Kotlin SDK
  • Use Presence APIs to determine who is currently chatting
  • The Message Persistence API will retrieve past messages for users newly joining the chat
  • Assign a 'friendly name' to yourself which will be available to others via the PubNub App Context storage APIs

Installing / Getting Started

To run this project yourself you will need a PubNub account

Requirements

PubNub Signup

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 Presence feature for your keyset. Also tick the box for 'Presence Deltas'

  7. Enable the Stream Controller feature for your keyset.

  8. Enable the Message Persistence feature for your keyset

  9. Enable the App Context feature for your keyset. Also enable 'user metadata events'

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

Building and Running

  • Clone the Github repository

git clone https://github.com/PubNubDevelopers/GettingStarted-Kotlin-SDK-Tutorial.git

  • Navigate to the application directory

cd GettingStarted-Kotlin-SDK-Tutorial

  • Add your pub/sub keys to gradle.properties

  • Open the application in Android Studio and run on device or with an emulator. Use multiple devices / emulators to simulate a more realistic chat experience.

Contributing

Please fork the repository if you'd like to contribute. Pull requests are always welcome.

Links

Checkout the following links for more information on developing chat solutions with PubNub: