Skip to main content
From cordova-moengage-core 11.0.0, the SDK registers Android devices for push using the Firebase Installation ID, which is the identifier that Firebase assigns to each installation of an application on a device. This change applies to Android only. The changes this migration requires depend on which component registers the push token in your application. Identify your case below, then complete the steps for that case.

Which Case Applies to Your Application

Case 1: The MoEngage SDK Registers the Token

This case is a breaking change. Complete all three steps, in order.

Step 1: Update the Firebase Messaging Library

Update com.google.firebase:firebase-messaging to 25.1.0 or higher. Refer to the Firebase Android release notes for this version.

Step 2: Enable the Firebase Installation ID

Add the following metadata to your application manifest file. In a Cordova project, add it through config.xml so that it persists when the Android platform is rebuilt. The <widget> element must declare the xmlns:android="http://schemas.android.com/apk/res/android" namespace.
Refer to the Firebase documentation on accessing the Firebase Installation ID for details.

Step 3: Upgrade the MoEngage SDK

Upgrade cordova-moengage-core to 11.0.0 or above. This version requires cordova-android 15.1.0 or later. Refer to the Cordova SDK release notes for the native SDK versions included in this release.

Impact

This migration is mandatory. Complete all three steps correctly, because an incomplete migration affects reachability and causes a push token drop. Without the metadata from Step 2, the SDK does not register for push, and debug builds crash at launch. If your application listens for the onPushTokenGenerated event on Android, also complete Step 6. From 11.0.0, the SDK no longer sends this event for FCM.

Case 2: Your Application Registers the Token

Complete Step 1, Step 2, and Step 3 from Case 1 first, then apply the API changes below. The replacement APIs are available only from cordova-moengage-core 11.0.0, so applying these changes before you upgrade results in errors. The following table summarizes the replacements. The first two apply to every integration in this case. The last applies only if your application listens for the event listed. The code blocks in the steps below show the replacement API only, so that the code you copy is the code you keep.

Step 4: Migrate onNewToken to onRegistered

In your native messaging service class, which extends FirebaseMessagingService, replace the onNewToken callback with onRegistered. The callback receives the Installation ID instead of the push token. The code block below is the replacement. Copy it as it is.
Refer to the Firebase documentation on the onRegistered callback for details.

Step 5: Migrate passFcmToken to passFirebaseInstallationId

Call passFirebaseInstallationId() in place of passFcmToken() to pass the Installation ID to the MoEngage SDK. The code block below is the replacement. Copy it as it is.
If your application passes the token from native Android code instead, follow Step 5 of the Android migration.

Step 6: Migrate onPushTokenGenerated to onFirebaseInstallationIdAvailable

Apply this step only if your application listens for the onPushTokenGenerated event on Android. Listen for the onFirebaseInstallationIdAvailable event instead. To read the Installation ID that the SDK holds at any time, call getFirebaseInstallationId(). The code block below is the replacement. Copy it as it is.

Impact

Case 2 is not a breaking change. Your application keeps registering for push on 11.0.0 without these API changes, because it supplies the identifier itself. Only Case 1 is mandatory. MoEngage still recommends the migration. The Installation ID remains available when Firebase refreshes or drops the push token, which keeps reachability consistent, and it replaces the token APIs, which are deprecated.