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.2 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.Step 3: Upgrade the MoEngage SDK
Upgrade to MoEngage Android BOM 4.4.0 or above. Refer to the Android SDK release notes for the module 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.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 MoEngage Android BOM 4.4.0, so applying these changes before you upgrade results in compilation errors. The following table summarizes the replacements. The first two apply to every integration in this case. The remainder apply only if your application currently calls the API listed. The code blocks in the steps below show the replacement API only, so that the code you copy is the code you keep.API reference links for
passInstallationId, registerForInstallationId, getInstallationId, and InstallationIdAvailableListener are added to this page once the reference for this release is published.Step 4: Migrate onNewToken to onRegistered
In your 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 passPushToken to passInstallationId
CallpassInstallationId in place of passPushToken to pass the Installation ID to the MoEngage SDK. This call is on MoEFireBaseHelper.
The code block below is the replacement. Copy it as it is.
Step 6: Migrate registerForToken to registerForInstallationId
Apply this step only if your application callsregisterForToken. Call registerForInstallationId in place of registerForToken. This call is on MoEFireBaseHelper.
This call is required only in the following cases:
- Firebase auto-initialization is disabled in your application. Refer to the Firebase documentation on preventing auto initialization.
- MoEngage SDK initialization is delayed, for example when your application initializes the SDK on a worker thread instead of in the
onCreate()method of the Application class.
The code block below is the replacement. Copy it as it is.
Step 7: Migrate getPushToken to getInstallationId
Apply this step only if your application callsgetPushToken. Call getInstallationId in place of getPushToken to read the identifier that the SDK holds. This call is on MoEFireBaseHelper.
The code block below is the replacement. Copy it as it is.
Step 8: Migrate the Token Listener Callback
Apply this step only if your application registers a token listener. CalladdInstallationIdListener and removeInstallationIdListener in place of addTokenListener and removeTokenListener, and replace TokenAvailableListener with InstallationIdAvailableListener, which receives an Installation ID result instead of a token. These calls are on MoEFireBaseHelper.
The code block below is the replacement. Copy it as it is.