Skip to content

FCM token handling on depersonalization

Ivan Krešić edited this page Oct 29, 2026 · 1 revision

FCM token handling on depersonalization

Supported on Android since version 16.3.0

This page explains what the SDK does with the Firebase Cloud Messaging (FCM) token when an installation is depersonalized or repersonalized, and how to opt out of it if your application manages the FCM token lifecycle by itself.

Table of contents

Default behavior

By default, after a successful depersonalization, the SDK resets the FCM token:

  1. it deletes the current token by calling FirebaseMessaging.deleteToken(),
  2. it requests a new token by calling FirebaseMessaging.getToken(),
  3. the new token is reported to Infobip, so the installation is no longer reachable via the previous token.

This is a privacy measure: a token that belonged to a previously logged-in user can't be used to deliver messages to the device anymore.

The SDK can also force a new token during repersonalization, when the push registration of the installation is no longer valid on the server side and there is no user data to restore.

Notice

Personalize with force depersonalization doesn't reset the FCM token. The installation is depersonalized on the server as part of the personalize request, and the SDK only performs its internal depersonalization cleanup, so the token stays the same regardless of the option described below.

When to let the application manage the FCM token

Resetting the token affects every component of the app that relies on the same FCM token, not only the Infobip SDK. You may want to disable it if:

  • your application (or another push provider used alongside Infobip, see custom FirebaseMessagingService) manages the FCM token itself and doesn't expect it to be replaced,
  • your application depersonalizes often as part of its regular flow (for example, on user logout or when switching between In-app chat conversations), and the token change disrupts push or chat functionality.

Enabling app-managed FCM token lifecycle

Use withAppManagedFcmTokenLifecycle(true) when initializing the SDK. The option is disabled by default.

MobileMessaging.Builder(application)
    .withAppManagedFcmTokenLifecycle(true)
    .build()
expand to see Java code

new MobileMessaging.Builder(application)
    .withAppManagedFcmTokenLifecycle(true)
    .build();

The value is applied on every build() call. If you remove the builder option (or pass false), the default behavior is restored on the next SDK initialization.

What changes when enabled

Scenario Default With withAppManagedFcmTokenLifecycle(true)
Depersonalization completed Token is deleted and a new one is requested Token is not deleted nor requested
Personalize with force depersonalization Token is not reset Token is not reset (unchanged)
Repersonalization without user data (push registration invalidated on server) New token is requested Token is not requested
SDK internal depersonalization cleanup (user data, primary flag, etc.) Performed Performed
New token received via MobileMessagingFirebaseService.onNewToken() Processed and reported Processed and reported
Application code change Token is deleted Token is deleted (unchanged)
Push service type change on SDK init Token is reset Token is reset (unchanged)

Responsibilities of the application

When the option is enabled, the FCM token keeps being used by the installation after depersonalization. If you need a new token, for example to make sure that messages targeted to the previous user can't reach the device, you have to rotate it yourself.

Notice

Calling FirebaseMessaging.getToken() doesn't trigger onNewToken() while the token stays the same. When your application obtains or rotates the token by itself, make sure it is passed to the SDK, so the SDK can (re)register it:

MobileMessagingFirebaseService.onNewToken(context, token)

Notice

If the push registration of the installation is invalidated on the server side (for example, because FCM no longer accepts the token), the SDK won't request a new token during repersonalization. The installation stays unregistered for push messages until a new FCM token reaches the SDK via MobileMessagingFirebaseService.onNewToken(). This happens automatically when Firebase issues a new token. If your application rotates the token by itself (deleteToken() + getToken()), pass the new token via MobileMessagingFirebaseService.onNewToken(context, token). Passing back the same token won't restore push delivery.

If you use a custom FirebaseMessagingService, keep forwarding new tokens to MobileMessagingFirebaseService.onNewToken() from your onNewToken() implementation, as before.

Clone this wiki locally