> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating to Firebase Installation ID

> Update the Android integration of your Flutter application to the Firebase Installation ID when you upgrade to moengage_flutter 11.1.0.

From `moengage_flutter` 11.1.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 migration applies only to Android. The iOS integration remains unchanged.

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

| Your integration | Case | Required |
| - | - | - |
| The MoEngage SDK registers the token. Your application uses `MoEFireBaseMessagingService`, which the plugin declares automatically from version 10.4.0, and does not opt out of token registration. | [Case 1](#case-1-the-moengage-sdk-registers-the-token) | Mandatory. This is a breaking change. |
| Your application registers the token through its own messaging service and passes it to the MoEngage SDK. | [Case 2](#case-2-your-application-registers-the-token) | Recommended. The previous APIs are deprecated. |

## 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

In the `android/app/build.gradle` file of your Flutter project, update `com.google.firebase:firebase-messaging` to 25.1.2 or higher. Refer to the [Firebase Android release notes](https://firebase.google.com/support/release-notes/android#messaging_v25-1-2) for this version.

### Step 2: Enable the Firebase Installation ID

Add the following metadata to the `android/app/src/main/AndroidManifest.xml` file.

```xml AndroidManifest.xml wrap theme={null}
<meta-data
    android:name="firebase_messaging_installation_id_enabled"
    android:value="true" />
```

Refer to the [Firebase documentation on accessing the Firebase Installation ID](https://firebase.google.com/docs/cloud-messaging/android/get-started#access-firebase-installation-id) for details.

### Step 3: Upgrade the MoEngage Plugin

Upgrade `moengage_flutter` to 11.1.0 or above. Refer to the [Flutter SDK release notes](https://moengage.com/docs/release-notes/sdks/flutter.md#17th-november-2026) for the plugin 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](#case-1-the-moengage-sdk-registers-the-token) first, then apply the API changes below. The replacement APIs are available only from `moengage_flutter` 11.1.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.

| Previous API | Replacement | Class | Applies when |
| - | - | - | - |
| `onNewToken` | `onRegistered` | Your messaging service class, which extends `FirebaseMessagingService` | Always |
| `passFCMPushToken` | `passFirebaseInstallationId()` | `MoEngageFlutter` | Always |
| `setPushTokenCallbackHandler` | `setFirebaseInstallationIdCallbackHandler()` | `MoEngageFlutter` | Your application sets a push token callback |
| None | `getFirebaseInstallationId()` | `MoEngageFlutter` | Your application needs to read the stored Installation ID |

### Step 4: Migrate onNewToken to onRegistered

In your Android messaging service class, which extends `FirebaseMessagingService`, replace the `onNewToken` callback with `onRegistered`. The callback receives the Installation ID instead of the push token.

| Previous | Current |
| - | - |
| `onNewToken(token: String)` | `onRegistered(installationId: String)` |

The code block below is the replacement. Copy it as it is.

```Kotlin Kotlin wrap theme={null}
override fun onRegistered(installationId: String) {
}
```

```Java Java theme={null}
@Override
public void onRegistered(@NonNull String installationId) {
}
```

Refer to the [Firebase documentation on the onRegistered callback](https://firebase.google.com/docs/cloud-messaging/android/get-started#implement-the-onregistered-callback) for details.

### Step 5: Migrate passFCMPushToken to passFirebaseInstallationId

Call `passFirebaseInstallationId()` in place of `passFCMPushToken` to pass the Installation ID to the MoEngage SDK. This call is on `MoEngageFlutter`.

| Previous | Current |
| - | - |
| `passFCMPushToken(String pushToken)` | `passFirebaseInstallationId(String installationId)` |

The code block below is the replacement. Copy it as it is.

```dart Dart theme={null}
final MoEngageFlutter _moengagePlugin = MoEngageFlutter(YOUR_WORKSPACE_ID);
_moengagePlugin.passFirebaseInstallationId(installationId);
```

### Step 6: Migrate the Push Token Callback

Apply this step only if your application sets a push token callback. Call `setFirebaseInstallationIdCallbackHandler()` in place of `setPushTokenCallbackHandler`, and replace `PushTokenCallbackHandler` with `FirebaseInstallationIdCallbackHandler`, which receives a `FirebaseInstallationIdData` object instead of `PushTokenData`. This call is on `MoEngageFlutter`.

| Previous | Current |
| - | - |
| `PushTokenCallbackHandler` | `FirebaseInstallationIdCallbackHandler` |
| `setPushTokenCallbackHandler(handler)` | `setFirebaseInstallationIdCallbackHandler(handler)` |

The code block below is the replacement. Copy it as it is.

```dart Dart theme={null}
_moengagePlugin.setFirebaseInstallationIdCallbackHandler(
    (FirebaseInstallationIdData data) {
  final String installationId = data.installationId;
});
```

### Step 7: Read the Stored Installation ID

Apply this step only if your application needs to read the identifier that the SDK holds. Call `getFirebaseInstallationId()`, which returns a `FirebaseInstallationIdData` object, or `null` if the SDK does not hold an Installation ID. This call is on `MoEngageFlutter`, and the plugin had no equivalent call for the push token.

The code block below shows the call. Copy it as it is.

```dart Dart theme={null}
final FirebaseInstallationIdData? data =
    await _moengagePlugin.getFirebaseInstallationId();
```

> [!NOTE]
>
> If your Android code calls `MoEFireBaseHelper` APIs directly, such as `registerForToken`, `getPushToken`, or `addTokenListener`, also complete the matching steps in the [Android migration guide](https://moengage.com/docs/developer-guide/android-sdk/migration/migrating-to-firebase-installation-id.md#case-2-your-application-registers-the-token).

### Impact

Case 2 is not a breaking change. Your application keeps registering for push on `moengage_flutter` 11.1.0 without these API changes, because it supplies the identifier itself. Only [Case 1](#case-1-the-moengage-sdk-registers-the-token) 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.