---
updatedAt: 2026-02-25T12:53:56.000Z
---

# Push notifications with FCM

Learn how to add push notifications to your app with Firebase Cloud Messaging (FCM).

The Kustomer Chat Android SDK uses Google Firebase Cloud Messaging (FCM) to send push notifications.

This tutorial covers how to add FCM to your app, configure push notifications in Kustomer, and handle push notifications in the SDK for users.

> 🚧 Firebase Cloud Message Server API Keys are being discontinued
>
> To ensure uninterrupted service to Android push notifications, you must upload your new FCM Private Key file to Kustomer **by June 20, 2024**. Legacy keys will no longer be supported after this date. For information on creating your new FCM Private Key file, see [Configure push notifications in Kustomer](https://developer.kustomer.com/chat-sdk/v2-Android/docs/push-notifications-with-fcm#step-2-configure-push-notifications-in-kustomer) below.

## Prerequisites

You'll need the following to set up push notifications with FCM:

* Access to your team's project in the [Google Firebase console](https://console.firebase.google.com/u/0/) and any necessary permissions for related tools (for example, Google Analytics).
* Admin permissions for your Kustomer organization to change [Chat Management: SDK](https://support.kustomer.com/en_us/chat-sdk-SyRjnij0P) settings.

### Step 1. Add Firebase Cloud Messaging to your app

First, use the Google Firebase console to add FCM to your app. To learn more, see [Add Firebase to Your Android Project](https://firebase.google.com/docs/android/setup) from the Google Firebase documentation.

1. Open your project in the [console for Google Firebase](https://console.firebase.google.com/u/0/). If you do not have an existing project, create a new one.

2. In your project, select **Add Firebase to your Android app** and follow the instructions to generate your `google-services.json` file.  For your package name, copy and paste the package used in your application `AndroidManifest.xml` file.

3. Save the **google-services.json** file generated by the tool at the root of your Android application (//google-services.json).

4. Follow the Gradle instructions, and modify your Project-level and App-level `build.gradle` files accordingly:

**Project-level**

```text Project-level build.gradle (<project>/build.gradle)
buildscript {
   dependencies {
       // Add this line
       classpath 'com.google.gms:google-services:4.3.3'
   }
}
```

**App-level**

```text App-level build.gradle (<project>/<app-module>/build.gradle)
// Add to the bottom of the file

apply plugin: 'com.google.gms.google-services'
```

5. After you modify your `build.gradle` files, select **Sync now** in the bar that appears in the IDE.

### Step 2. Configure push notifications in Kustomer

After you add FCM to your app, navigate to the Firebase console and download the FCM Private Key file under Project Settings. Once the FCM private key file download is complete, open your Kustomer account and configure push notifications on your [Chat Management: Install Chat](https://help.kustomer.com/en_us/chat-sdk-SyRjnij0P#mobile-sdk) settings page.

1. You'll need your FCM Private Key file to configure Android SDK settings for push notifications in the Kustomer platform. To locate your FCM Private Key file in your Firebase project, go to **Project Overview > Project settings**.

[block:image]{"images":[{"image":["https://files.readme.io/355cabb-Screenshot_2024-05-13_at_9.21.57_AM.png","","Firebase Project settings"],"align":"center","caption":"Firebase Project settings"}]}[/block]

2. Go to the **Service accounts** tab and select **Generate new private key**.

[block:image]{"images":[{"image":["https://files.readme.io/62201f5-light_firebase_service_accounts.png","","FIrebase Service Accounts"],"align":"center","caption":"FIrebase Service Accounts"}]}[/block]

3. Then select **Generate Key** to download the private key file.

[block:image]{"images":[{"image":["https://files.readme.io/0c251cb-light_generate_new_key.png","","Generate a private key"],"align":"center","caption":"Generate a private key"}]}[/block]

4. Once the private key file is downloaded, open Kustomer as an Admin user, go to **Apps > Chat**, and select the **Install Chat** tab.
5. **Upload the FCM Private Key file** in the Android section of the page and then select **Save Changes** to create a keyset for the Android SDK.

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/72146c0-kustomer_push_updated.png",
        "",
        "Upload your FCM private key file to configure your Android push notification settings in Kustomer"
      ],
      "align": "center"
    }
  ]
}
[/block]

> 📘
>
> The ability to upload the Private Key file is currently being rolled out to organizations in stages. If you are ready to complete the migration and do not see the Upload option, contact <support@Kustomer.com>.

### Step 3. Register device for push notifications

You can implement one of the following options to distinguish Kustomer push notifications from your own app push notifications:

* Use `registerDevice` to have the Kustomer SDK fetch the device token from `FirebaseInstanceId` and to register the device token.

```kotlin Kotlin: Fetch and register device token on &#x60;onActivityCreated&#x60;
Kustomer.getInstance().registerDevice()
```

> 📘 Call registerDevice after Kustomer is initialized
>
> Call `registerDevice` either in the `Kustomer.init()` call back or on `onActivityCreated` to ensure your Application class has initialized before you call `registerDevice`.

* Use `registerDeviceToken(token)` to register the device with a token that you specify yourself.

```kotlin Kotlin: Notifies Kustomer on device token changes
suspend Kustomer.getInstance().registerDeviceToken(token){
            when (it) {
                is KusResult.Success -> it.data
                is KusResult.Error -> it.exception.localizedMessage
            }
        }
```

### Step 4. Forward Kustomer push notifications to the SDK

**If your Android app doesn't handle push notifications yet**, the Kustomer SDK adds its own implementation of `FirebaseMessagingService` to your `AndroidManifest` and automatically handles the notifications. Continue to [Step 5](#step-5-deregister-devices-for-push-notifications) to learn how to deregister devices for push notifications.

If your app already has an implementation of `FirebaseMessagingService`, you'll need to override `FirebaseMessagingService` on `onMessageReceived` and identify whether or not an incoming `remoteMessage` is a Kustomer push notification. You don't need to do anything with Kustomer push notifications because the SDK will handle these automatically. If needed, add any handling you require for the push notifications from your own app.

```kotlin Kotlin: onMessageReceived
override fun onMessageReceived(remoteMessage: RemoteMessage) {

        //Push notification received
        val isKustomerPush = KusNotificationService.onMessageReceived(remoteMessage: RemoteMessage, applicationContext: Context, customBackStack: TaskStackBuilder?)
        if (isKustomerPush) {
            //Do nothing
        } else {
            //DO HOST LOGIC HERE
        }
    }
```

> 📘 Notes:
>
> * **Allowed message types for remote messages**\
>   The Kustomer Chat Android SDK will ignore any remote messages that aren't one of the allowed chat [Message Types](https://developer.kustomer.com/chat-sdk/docs/message-template-types).
> * **Override for the push notification icon**\
>   To override the small push notification icon, you can create an icon in the Client app with the name `ic_kus_chat_notification`.
> * **Pass an optional backstack when the SDK launches from a push notification**\
>   By default, launching the chat widget from a push notification will do so without any app Activity on the backstack and navigating up/back beyond the root of the SDK will close it. To pass a custom backstack that leaves the end user in your app after they've navigated up/back away from the SDK, you can pass an optional `TaskStackBuilder`.

### Step 5. Deregister devices for push notifications

> 👍 Deregister devices for new user logins
>
> Always deregister the device from receiving push notifications for new user logins. This ensures that the new user does not receive push notifications for any previously logged in users.

To deregister devices for push notifications, implement the following:

```text Kotlin: deregisterDeviceForPushNotifications
suspend Kustomer.getInstance().deregisterDeviceForPushNotifications{
            when (it) {
                is KusResult.Success -> it.data
                is KusResult.Error -> it.exception.localizedMessage
            }
        }
```

## Customize push notifications

You can [customize your push notifications content](https://help.kustomer.com/chat-sdk-SyRjnij0P#customize-notifications) to redact sensitive information from within the Kustomer platform. To make these changes, go to **Apps > Chat** and select the **Install Chat** tab.