This repository contains sample code for a chat application built using the PubNub Android SDK.
Directory | Description |
---|---|
app/examples/animal/forest/chat |
Source files for the Animal Forest Chat application. |
- Android Studio 3.0+
- PubNub SDK
- A PubNub Chat account
To run this application you must obtain publish and subscribe keys from your PubNub Dashboard. If you don't already have an account, you can create one for free.
-
Sign in to your PubNub Dashboard.
-
Click Create New App. Give your app a name, and select Chat App as the app type. Select a region to store your user data (e.g. Portland). Click Create.
-
Click your new app to open its settings, then click its keyset.
-
Locate the Publish and Subscribe keys. You'll need these keys to include in this project.
Execute the following commands to add your publish and subscribe keys to your local copy of the app.
cd app/
echo PUB_KEY="\"YOUR_PUBNUB_PUB_KEY\"" >> gradle.properties
echo SUB_KEY="\"YOUR_PUBNUB_SUB_KEY\"" >> gradle.properties
echo app/gradle.properties >> ../.gitignore
This will also create a app/gradle.properties
file, which is a good place to store confidential information.
-
Launch Android Studio. On the welcome screen, choose Open an existing Android Studio project.
-
Select the root project folder,
chat-examples-java/
, and click Open. -
Wait for Gradle to download dependencies and sync the project. This could take several minutes.
-
Choose Run > Run 'app', and pick the device on which you want to run the app. If necessary, create a new virtual device on which to run the app.
For more information about this project, or how to create your own chat app using PubNub, please check out the PubNub Chat Documentation.