Real time Messaging

Overview

This guide will show you how to configure an Android app to handle real-time messaging such as a chat client or group texting app. There are several approaches you can take to achieve this.

PubNub

One approach is to use the PubNub service to send and receive real-time messages. PubNub enables low-latency real-time apps that work across any number of platforms including Android, iOS, and Javascript.

Setup

PubNub can be setup very quickly using this setup guide for their Android SDK. In short, their SDK is contained within two JARs that need to be added to your app's libs folder. You can also watch this setup video to get a better look.

Usage

PubNub works by allowing any number of clients to subscribe and send messages to any number of different channels. All clients subscribed to a channel will get messages sent to that channel in real-time.

PubNub

To subscribe and send messages to a channel, we leverage the easy-to-use Android SDK. Check out this step-by-step tutorial as well as this handy quickstart guide. We can also take a look at the Android PubNub Code which includes a detailed README. A complete example of using PubNub can be found within this example.

If we want to use PubNub as a service such that the messages are being received even when the app isn't open, we can check out this simple example which describes how to setup a PubNubService which subscribes to a channel and receives messages starting up as soon as the device boots. This solution is expanded on in this stackoverflow post.

Sinch

Check out this detailed guide for creating a real-time messaging client using Sinch.

Applozic

Applozic powers real time chat and messaging on android, iOS, phonegap and web apps. Applozic Chat SDK allows developers to add whatsapp like chat capabilities to their apps including group chat, image, file, location sharing, audio/video messages, contextual chat and a lot more.

Refer to the Android Chat SDK to get started. Check out this detailed instruction for adding a real time chat sdk into your Android, iOS, Phonegap and Web app.

References

Fork me on GitHub