Using the AppMetrica Push SDK with Firebase Cloud Messaging

You can use the AppMetrica Push SDK with Firebase Cloud Messaging (FCM) at the same time. To do this, you need to create the FCM service that will redirect messages between integrated SDKs.

The section below describes the steps for setting up FCM:

Step 1. Make changes in AndroidManifest.xml

Make changes in the application element in the AndroidManifest.xml file:

<service android:name=".FirebaseMessagingMasterService"
    <intent-filter android:priority="100">
        <action android:name=""/>
<service android:name="" tools:node="remove"/>
Copied to clipboard

Step 2. Add push notifications handling

Declare the derived FirebaseMessagingMasterService class from the base FirebaseMessagingService class for handling push notifications:

public class FirebaseMessagingMasterService extends FirebaseMessagingService {
    public void onMessageReceived(RemoteMessage message) {
        // AppMetrica automatically recognizes its messages and processes them only.
        new MetricaMessagingService().processPush(this, message);

        // Implement the logic for sending messages to other SDKs.
Copied to clipboard