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
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)
- 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
To run this project yourself you will need a PubNub account
- Android Studio. Any recent version will work but this app was initially created with Android Studio Chipmunk.
- PubNub Account (Free)
-
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.
-
Sign in to your PubNub Dashboard.
-
Click Apps, then Create New App.
-
Give your app a name, and click Create.
-
Click your new app to open its settings, then click its keyset.
-
Enable the Presence feature for your keyset. Also tick the box for 'Presence Deltas'
-
Enable the Stream Controller feature for your keyset.
-
Enable the Message Persistence feature for your keyset
-
Enable the App Context feature for your keyset. Also enable 'user metadata events'
-
Copy the Publish and Subscribe keys and paste them into your app as specified in the next step.
- 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.
Please fork the repository if you'd like to contribute. Pull requests are always welcome.
Checkout the following links for more information on developing chat solutions with PubNub:
- Chat Real-Time Developer Path: https://www.pubnub.com/developers/chat-real-time-developer-path/
- Tour of PubNub features: https://www.pubnub.com/tour/introduction/
- Chat use cases with PubNub: https://www.pubnub.com/use-case/in-app-chat/