MoEngage Docs

Configuring FCM

Before configuring FCM please make sure General Push Configuration is completed.

Please make sure you have a completed Firebase Setup before proceeding further time.

Latest version of MoEngage SDK(9.2.00 and above) is compiled with 17.3.2 hence expecting the client app to use Firebase version 17.3.2. However, we do support versions below 17.1.0 but your application needs to handle the token registration mechanism.

Adding Listener Service

In case MoEngage is the only push provider you can use the firebase services provided by the MoEngage SDK. To use the service add the following snippet in your manifest file.

In case you are migrating from an older version of Firebase library(17.3.2 and below) remove the already added Firebase listener/service provided by MoEngage SDK and add the below.

    <service android:name="com.moengage.firebase.MoEFireBaseMessagingService">
      <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
      </intent-filter>
    </service>

Using your own listener service

In case you have multiple push providers you should have only one service in your manifest file and pass on the payload to all providers. To pass payload to MoEngage SDK use the following snippet

public class FireBaseMessagingListenerService extends FirebaseMessagingService {
  @Override public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage != null){
      Map<String, String> pushPayload = remoteMessage.getData();
      if (MoEngageNotificationUtils.isFromMoEngagePlatform(pushPayload)){
        PushManager.getInstance().getPushHandler().handlePushPayload(getApplicationContext(), pushPayload);
      }else {
        //your own logic
      }
    }
  }

Note

At any point your application's manifest should have only one service with intent filter com.google.firebase.MESSAGING_EVENT and one service with intent filter com.google.firebase.INSTANCE_ID_EVENT. If there are more than one service with either of the intent filters it could lead to poor notification delivery.

Testing Push Notification

Refer to this link to read more about how to create and test push notifications.


Configuring FCM


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.