Tutorial: Build an Android chat app with PubNub

Learn how to build a scalable chat app using the PubNub Android SDK getting started tutorial.

Step 01

Build a Chat App with the PubNub Android SDK

This tutorial will walk you through developing a basic chat application in Kotlin using PubNub.  

This tutorial will focus on the Kotlin SDK and not the community-supported chat UI components designed for Kotlin.  

The source code for this application can be found on Github at https://github.com/PubNubDevelopers/GettingStarted-Kotlin-SDK-Tutorial

Prerequisites

Before running this application, be sure you have the following installed:

  • Android Studio.  The application was created with version ‘chipmunk’ but should work with any recent version of the IDE.

Download Source Application

In a terminal, navigate to an empty folder.  Enter the following command to clone the repository:

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

The main git branch contains the completed version of this tutorial.  If you would like to follow along, please checkout the following branch:

git checkout tutorial_step_0

Step 02

Create keys

Demo keys

You're ready to go!

We’ve assigned demo keys which are set up to support the features of this tutorial app. These will be active for 72 hours but you can sign up for a free account at the end of the tutorial to create your own permanent keys.

The demo keys have the following functionality activated ready for your application:

  • Presence

  • Message Persistence You will be able to see user’s message history and meta data.

  • Stream Controller You will be able to receive messages against a group of channels, or post one message to multiple channels.

  • App Context This allows you to manage the metadata of your users and channels.

My own keys

To use your own keys, create a free account and a keyset with Presence, Message Persistence, Stream Controller, and App Context on.

You can create the keyset with the Admin API, PubNub's REST API for account management. An Account Owner or Account Admin creates a Service Integration and its API key in the Admin Portal under Organization Settings → API Management. Give it read & write access to apps and keysets, plus read access to secret keys, which keyset creation requires. With that key, create an app, then create a keyset in it and pass the keyset's configuration in the same request. The response includes the publish and subscribe keys. See the Admin API documentation for the requests and keyset settings.

Step 03

Build and run

Step 04

Congratulations - what's next?

Chat SDK Documentation

Chat OverviewKotlin SDK DocsChat Developer Path

Live Tour

Start the live coding tour

Developing to a tight deadline? Explore Chat Components

Chat Components IntroductionChat Components Documentation (Android)

Ready to get beyond Proof of Concept?

Schedule a 15 minute chat with one of our experts to get your project moving

Talk to an Expert
Keep building

Take it to production on your own keys

Create a free PubNub account to get permanent keys for this app.