Introduction: Firebase Cloud Messaging (FCM) Wrapper for Android
More: Author   ReportBugs   

AndroidStudio 3.1.4 minSDK 16 targetSDK 27

Pushmanager is a small wrapper for FCM (Firebase Cloud Messageing) and your app needs just a few methods to interact with it.


Add google-services as dependency to your project build.gradle

buildscript {
    dependencies {
        classpath ""

and add jitpackto your repositories

allprojects {
    repositories {
        maven { url "" }

Add this dependency to your app build.gradle and apply the plugin at the bottom:

implementation 'com.github.grumpyshoe:android-module-pushmanager:1.2.1'
apply plugin: ''


Get instance of PushManager:

val pushmanager: PushManager = PushManagerImpl

Put your google-services.json to the app-root folder.

Create a class extending PushmanagerMessagingService and implement handleNotificationPayload.

class MyService : PushmanagerMessagingService() {

    override fun handleNotificationPayload(context:Context, remoteMessageData: RemoteMessageData): NotificationData? {

      Log.d("PushManager", "handlePayload - ${remoteMessageData.title} - ${remoteMessageData.body}" )

      // create pending intent (example)
      val notificationIntent = Intent(context,
      notificationIntent.putExtra("info", "Some information for pending intent")
      notificationIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
      val contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT)

      // create notification (example)
      return NotificationData(
            context = context,
            title = remoteMessageData.title ?: "Default Title",
            message = remoteMessageData.body ?: "Default Message",
            channelId = "channel_global_notifications",             // needed SDK >= Android O
            autoCancel = true,
            pendingIntent = contentIntent)

Add your implementation to you Manifest.xml

<application ... >

               <action android:name=""/>


Register to FCM

Call the method register in your onCreate to register to FCM.

      context = this,
      onTokenReceived = { token ->
          Log.d("PushManager", "token received: $token")
      onFailure = { exception ->
          Log.d("PushManager", " error during registration: ${exception?.message}")

Unregister from FCM

To unregister from FCM you need to register first. By using the token you received, you are able to unregister.

pushmanager.unregister(context, token)


Subscribe to Topic

To subscribe to a topic just call subscriptToTopic:

      topic = "wurst",
      onSuccess = {
          Log.d("PushManager", "successfully subscribed")
      onFailure = { exception ->
          Log.d("PushManager", " error while subscribing: ${exception?.message}")

Unsubscribe from Topic

To unsubscribe from a topic call unsubscriptFromTopic:

      topic = "wurst",
      onSuccess = {
          Log.d("PushManager", "successfully unsubscribed")
      onFailure = { exception ->
          Log.d("PushManager", "error while unsubscribing: ${exception?.message}")


Package Version 16.0.1 17.0.0 17.3.0

Sample App

To run the sample App, just replace the application_id at the project build.gradle with someone according to your firebase project and add your google-services.json to to app root folder.


See Troubleshooting at github wiki.

Need Help or something missing?

Please submit an issue on GitHub.


This project is licensed under the terms of the MIT license. See the LICENSE file.

Other information



  • Change PendingIntent handling and move it's logic to NotificationData.


  • Change structure of how to implement payload handling


  • Make return value for handleNotificationPayload nullable. If this method returns null no notification will be generated.

Build Environment

Android Studio 3.1.4
Build #AI-173.4907809, built on July 23, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.4
Support Me
About Me
Google+: Trinea trinea
GitHub: Trinea