Push Notifications: Android overview

Pusher’s Mobile Push Notifications API has first-class support for native Android applications. Your Android app instances subscribe to interests; then your servers send push notifications to those interests. Every subscribed app will receive the notification, even if the app is not open on the device at the time. This section describes how you can set up an Android app to receive push notifications through Pusher.

The steps to getting Push Notifications working on Android are:

  1. Create a project with Firebase Cloud Messaging (or Google Cloud Messaging).
  2. Get your google-services.json and Server Key.
  3. You pass your Server Key to the Pusher dashboard.
  4. You create or configure an Android app to use the Pusher client library.
  5. You configure your Android app to subscribe to an interest when launched.
  6. You launch your Android app. It subscribes to an interest.
  7. You use a Pusher server library to send a push notification to that interest.
  8. Your running Android app receives the push notification!

This diagram highlights the systems involved in this process:

                                     +--------------------------------------+
                                     |                                      |
                                     |                                      |
      +----1.register----------------+            YOU/YOUR SERVER           |
      | +--2.API key----------------->                                      |
      | |                            |                                      |
      | |                            +---------------+                      |
      | |                            | pusher server |                      |
      | |                            | library       |                      |
      | |                            +-------+-------+-------------+--------+
      | |                                    |                     |
      | |                                    |                     |
      | |                               6.publish              3.API key
      | |                                    |                     |
      | |                                    |                     |
      | |                            +-------v---------------------v--------+
      | |                            |                                      |
      | |                            |                                      |
+-----v-+------+                     |                                      |
|              |                     |                                      |
|  FCM or GCM  <----7.notification---+               PUSHER                 |
|              |                     |                                      |
+-----+-^------+                     |                                      |
      | |                            |                                      |
      | |                            |                                      |
      | |                            +------------------^-------------------+
      | |                                               |
      | |                                               |
      | |                                     5.register/subscribe
      | |                                               |
      | |                                               |
      | |                                     +-------------------+
      | |                                     | +---------------+ |
      | +----4.register-------------------------+ pusher client | |
      +------8.notification---------------------> library       | |
                                              | +---------------+ |
                                              |                   |
                                              |    YOUR USER'S    |
                                              |   ANDROID CLIENT  |
                                              |                   |
                                              +-------------------+

GCM or FCM

FCM (Firebase Cloud Messaging) is the primary platform used for push notifications on Android. FCM is a replacement for an older, similar system called GCM (Google Cloud Messaging). FCM inherits GCM’s infrastructure and is the basis on which Google’s future Cloud Messaging features will be built. FCM messages can also target apps set up with GCM.

We have two Android guides: one for FCM and one for GCM. We recommend using FCM. This will allow you to keep up with new features on the FCM platform. As Google will continue to support FCM, so will we.

Each guide is split into three sections, covering all stages of setting up your Android app:

  1. Setting up FCM or GCM. This guides you through getting a Server Key to use with FCM/GCM, and uploading that key to the Pusher dashboard.
  2. Setting up your Android client for FCM or GCM. This guides you through adding the Pusher client library to your Android app, getting the app to register with FCM/GCM and with Pusher, subscribing to interests, and receiving notifications.
  3. Pushing to your Android client via FCM or GCM. This guides you through sending your first push notification to your Android app, and then explains some more advanced options when sending notifications.

After that process, you may wish to set up an iOS app for push notifications, too. You can then send to both iOS and Android apps at the same time, with a single push from your server.

Have you tried using the search to find what you’re after? If you still have a question then get in touch with us and let us help you out.