This project is the open-source Android Application JetNews integrate with chat using PubNub’s Chat Components for Android. This application was built to showcase how easy it is to add chat to an existing application without the need of massive overhead and managing your own servers. A detailed tutorial is available for a step-by-step guide on how easy it is to integrate chat into your own application.
The open-source application used is JetNews, which is a sample news reading app built with Jetpack Compose.
This application contains the base JetNews functionality along with a chat room for each article for users to be able to chat about the article they have just read. Users can view a list of articles, read each article, and chat about these articles with other users.
- Pre-built UI Component that renders and handles displaying the chat room.
- Send messages to other users in the chat room.
- Receive messages from other users in the chat room.
- See past messages from other users in the chat room, even if the current user is offline.
- See typing indicators from users in the debug console and interact with the Android app in real-time.
Put a short explanation of the steps below and what the developer should accomplish at the end. For example: “For this project we’ll use NPM to install dependencies and run the project. You’ll also need a PubNub account.”
- Sign in to your PubNub Dashboard. You are now in the Admin Portal.
- Go to Apps on the left hand side of the Portal.
- Click the Create New App button in the top-right of the Portal.
- Give your app a name.
- Click Create.
- Click your new app to open its settings.
- When you create a new app, the first set of keys are generated automatically. However, a single app can have as many keysets as you like. PubNub recommends that you create separate keysets for production and test environments.
- Click on the keyset generated.
- Enable the Presence feature for your keyset. This will be used to show how many users are active. Enter "ENABLE" in all caps to confirm your choice. Leave the default settings.
- Enable the Storage and Playback feature for your keyset. Leave the default settings.
- Click Save Changes on the bottom right of the portal to save your changes.
- Copy the Publish and Subscribe Keys to a text editor.
-
Clone the GitHub repository.
git clone https://github.com/olivercarson-pubnub/jetnews-with-chat.git
-
Open the JetNews Folder in Android Studio.
-
Open the gradle.properties file.
-
Replace the PUBNUB_PUBLISH_KEY and PUBNUB_SUBSCRIBE_KEY values with your own publish and subscribe keys respectively.
-
Sync the gradle file and run the application.
-
Click on an article to read.
-
Click on the chat message icon on the bottom toolbar to open the chat room.
-
Send and receive messages, and view past messages from other users.
-
Generate new users each time the application is restarted.
-
Receive messages in real-time by interacting with the debug console.
Please fork the repository if you'd like to contribute. Pull requests are always welcome.
- Project homepage: https://pubnub.com
- Blog post: https://www.pubnub.com/blog/how-to-add-chat-to-android-application-with-pubnub/
- Swift Weather Application integrated with chat using PubNub's Chat Components for iOS: https://github.com/PubNubDevelopers/Swift-Weather-Chat/
Checkout PubNub Android Chat Docs page for more information about how to use Android Chat Components in your own Android app.
Copyright 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.