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
Updatecom.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 throughconfig.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.
Step 3: Upgrade the MoEngage SDK
Upgradecordova-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 theonPushTokenGenerated 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 fromcordova-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 extendsFirebaseMessagingService, 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.
Step 5: Migrate passFcmToken to passFirebaseInstallationId
CallpassFirebaseInstallationId() 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.
Step 6: Migrate onPushTokenGenerated to onFirebaseInstallationIdAvailable
Apply this step only if your application listens for theonPushTokenGenerated 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.