Enable Push Notifications

Learn how to enable Android push notifications in Brand Messenger Legacy's SDK

The SDK supports Firebase Cloud Messaging (FCM) for push notifications. See FCM Architectural Overview to learn more about the service and requirements for implementation.

To get started with push notifications with FCM, you'll need to:

  • Generate an FCM configuration file for your project
  • Send your Server API Key and Sender ID to Khoros
  • Create a notification service class
  • Add your service to the application's manifest

Generate a FCM configuration file for your Android project

Enable Cloud Messaging for your app and create a server API key.

  1. Go to Google’s Firebase Console.
  2. If you do not have a project already, create a new one.
  3. Once created, click Add Firebase to your Android app and follow the instructions to generate the google-services.json file. For your package name, copy and paste the package used in your application’s AndroidManifest.xml file.
  4. Save the google-services.json file generated by the tool at the root of your Android application (//google-services.json).
  5. Follow the Gradle instructions and modify your build.gradle files.

The project-level build.gradle (/build.gradle):

buildscript {
   dependencies {
       // Add this line
       classpath 'com.google.gms:google-services:3.2.0'

Module-level build.gradle (//build.gradle):

dependencies {
   // Add this line
   compile 'com.google.firebase:firebase-core:12.0.1'
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

Finally, select Sync Now in the bar that appears in the IDE.


If your app has its own token registration, you need to trigger Brand Messenger Legacy push notifications by calling the triggerBrandMessengerNotification method on FcmServiceclass.

Send your Server API Key and Sender ID to Khoros

Send your Server API Key and Sender ID to Khoros Support. To retrieve the key and ID, click on the Settings icon (a cogwheel) next to Project Overview on the sidebar, and then select the Cloud Messaging tab).

Create a Notification Service Class

After FCM enablement and configuration, create a notification service class and extend FirebaseMessagingService.

public class NotificationService extends FirebaseMessagingService {

   public void onMessageReceived(final RemoteMessage message) {
       final Map data = message.getData();

       FcmService.triggerBrandMessengerNotification(data, this);

Add Your Service to the Application's Manifest

Add your created service to the Manifest.xml under application.

Here is an example:

       <action android:name="com.google.firebase.MESSAGING_EVENT"/>

If you are using Android Nougat or later, include the following to ensure your app's notifications are visible to the user and that user has the ability to turn them off in their settings.



default_notification_channel_id is the notification channel id which can be custom to your app.