Firebase Push (FCM)

This will guide you to integrate FCM push notifications in android applications using SuprSend

This section is a step-by-step guide to integrate FCM as your service provider for sending Android Push notifications.

Step-1. Create Firebase project in firebase console

To start sending notifications from FCM, you'll have to first create a firebase project. Create firebase project and application in firebase console with your applications package name which you can find in or AndroidManifest.xml.

Step-2. Adding google-services.json

You can get your Service Account JSON by following these instructions. Download google-services.json and add the file inside your android>app folder.

Step-3. Adding Firebase dependencies and plugins

3.1. Add below dependency inside projects build.gradle inside dependencies

dependencies {
        classpath '' // or latest version

3.2. Add below plugin inside apps build.gradle

apply plugin: ''

3.3. Add below dependency inside apps build.gradle inside dependencies

implementation("") // or latest version

Step-4. Implementing push

Push feature can be implemented in two ways:

Option 1 - Token Generation and Notification handled By SDK

You may use this option if all of your android push notifications are to be handled via SuprSend SDK. We recommend you to use this method as it is just a single step process to just register the service in your application manifest and everything else will be ready.

<uses-permission android:name="android.permission.INTERNET" />
<!--If you are targeting to API 33 (Android 13) you will additional need to add POST_NOTIFICATIONS -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

        <action android:name="" />

Option 2 - Token Generation and Notification handled By Your Application:

Since your service is registered in the app manifest, to render the push notification directed from SuprSend server you will have to add the below code to your service

import android.util.Log
import app.suprsend.SSApi
import app.suprsend.notification.SSNotificationHelper
import app.suprsend.notification.isSuprSendRemoteMessage

class YourAppFirebaseMessagingService  : FirebaseMessagingService() {

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        try {
            if (remoteMessage.isSuprSendRemoteMessage())
                SSNotificationHelper.showFCMNotification(applicationContext, remoteMessage)
        } catch (e: Exception) {
            Log.e(TAG, "onMessageReceived", e)

    override fun onNewToken(token: String) {
        try {
            Log.i(TAG, "FCM Token : $token")
            val instance = SSApi.getInstance()
        } catch (e: Exception) {
            Log.e(TAG, "onNewToken", e)

    companion object {
        const val TAG = "app_push_fcm"
import android.util.Log;

import androidx.annotation.NonNull;


import app.suprsend.SSApi;
import app.suprsend.notification.SSNotificationHelper;
import app.suprsend.notification.SSNotificationHelperKt;

class YourAppFirebaseMessagingService extends FirebaseMessagingService {

    private final String TAG = "app_push_fcm";

    public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
        try {
            if (SSNotificationHelperKt.isSuprSendRemoteMessage(remoteMessage)) {
                SSNotificationHelper.INSTANCE.showFCMNotification(getApplicationContext(), remoteMessage);
        } catch (Exception e) {
            Log.e(TAG, "onMessageReceived", e);

    public void onNewToken(@NonNull String token) {
        try {
            Log.i(TAG, "FCM Token : $token");
            SSApi instance = SSApi.Companion.getInstance();
        } catch (Exception e) {
            Log.e(TAG, "onNewToken", e);


Step-5. Sending the FCM token to SuprSend

class YourApplication : Application() {

    override fun onCreate() {
    FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
        if (!task.isSuccessful) {
            Log.w(TAG, "Fetching FCM registration token failed", task.exception)
        val fcmToken = task.result

    //or if you are on older FCM version

    val fcmToken  = FirebaseInstanceId.getInstance().token

Asking for permission -Android 13(API-33)

import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.viewpager.widget.ViewPager
import org.json.JSONObject

class YourActivity : AppCompatActivity() {
    private val activityResultLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted: Boolean ->
        if (!isGranted) {
            // You can show a dialog which explains the intent of this permission request of how it is important for certain features of your app to work
                .setPositiveButton("Proceed") { _, _ ->
                    val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    val uri: Uri = Uri.fromParts("package", packageName, null)
           = uri
                .setNegativeButton("Deny") { _, _ ->
    override fun onCreate(savedInstanceState: Bundle?) {

If androidx dependency is not present then you will have to add the below dependency in your app dependencies

dependencies {


How to identify if notification is sent by SuprSend?

If notification payload contains key supr_send_n_pl then simply consider this as payload sent from suprsend and pass the payload to suprsend sdk by:

if (payload?.data?.supr_send_n_pl) {

What’s Next

Add FCM vendor configuration on SuprSend dashboard vendor page to start sending notification