Migrating to Installation ID

Migrate Cloud Messaging from FCM registration tokens to Firebase Installation ID (FID) registration.

Upstream Firebase SDKs prefer Firebase Installation ID (FID) registration over FCM registration tokens. React Native Firebase exposes register, unregister, onRegistered, and onUnregistered for that path. FID messaging is off by default — you must opt in before calling those APIs.

This guide covers the client migration: API mapping, opt-in, iOS APNs vs register(), backend storage of each FID, and the error codes you will see when the flag and API choice disagree. Full native / Expo config samples and listener semantics live under Installation ID messaging.

Table of contents

Agent-assisted migration

This guide is written to be complete enough for an automated first pass. Feed this document to your coding agent, then ask it to analyze your codebase against each section below and produce a concrete change list (or PR). Use the Automated migration checklist at the end for search/replace and validation steps.

API mapping

Before (FCM token APIs)After (FID registration)Notes
getToken(messaging)register(messaging) + onRegisteredPrefer listening with onRegistered; call register() to start registration
onTokenRefresh(messaging, cb)onRegistered(messaging, cb)FID rotations deliver through onRegistered
deleteToken(messaging)unregister(messaging) (+ optional onUnregistered)onUnregistered only fires for calls after you subscribe

Token APIs remain usable while the Installation ID flag is off. After opt-in, getToken and deleteToken reject and onTokenRefresh throws; while the flag is still off, register and unregister reject and onRegistered and onUnregistered throw (see Error codes).

Opt-in

Prefer firebase.json for bare React Native (same pattern as messaging_auto_init_enabled):

json
{
  "react-native": {
    "messaging_installation_id_enabled": true
  }
}

That key maps to:

SurfaceKey / prop
Android meta-datafirebase_messaging_installation_id_enabled
iOS Info.plistFirebaseMessagingInstallationIdEnabled
Expo config plugininstallationIdEnabled

Bare Android / iOS keys and the Expo plugin prop remain valid if you set them yourself instead of (or in addition to) firebase.json. Do not duplicate full Manifest / plist / Expo JSON blocks here — copy from Installation ID messaging.

Rebuild native apps after changing the flag (pod install / Expo prebuild as applicable).

APNs registration vs register()

register() does not replace registerDeviceForRemoteMessages.

On iOS you still need APNs registration before remote pushes arrive (auto-registration by default, or a manual registerDeviceForRemoteMessages call when auto-registration is disabled). FID registration is a separate step for Installation ID messaging.

Backend: store the FID

When the flag is on, upload the FID from onRegistered (and remove it on onUnregistered / unregister) the same way you previously stored FCM tokens — typically keyed by user in your datastore. Treat FID rotations like token refreshes: update or insert the new value when onRegistered fires again.

For end-to-end client samples (listeners, replay behavior, Expo / native keys), see Installation ID messaging.

Error codes

CodeWhen
messaging/installation-id-not-enabledFID APIs (register, unregister, onRegistered, onUnregistered) while the flag is off
messaging/token-api-disabledToken APIs (getToken, deleteToken, onTokenRefresh) while the flag is on

Enable the flag before switching call sites, or keep token APIs until you are ready to opt in.

Automated migration checklist

Use this section for scripted or agent-assisted migrations.

1. Opt in

Add or confirm:

json
{
  "react-native": {
    "messaging_installation_id_enabled": true
  }
}

Or set Android firebase_messaging_installation_id_enabled, iOS FirebaseMessagingInstallationIdEnabled, or Expo installationIdEnabled: true — see Installation ID messaging.

2. Agent-oriented search and replace

Search forReplace with / action
getToken( (messaging)Prefer register( + onRegistered(; stop calling getToken after opt-in
onTokenRefresh(onRegistered(
deleteToken( (messaging)unregister(; optionally subscribe with onUnregistered(
Backend stores of FCM tokens from messagingStore FID from onRegistered / clear on unregister / onUnregistered
Assume register() implies APNsKeep registerDeviceForRemoteMessages / auto-registration for iOS pushes
messaging/installation-id-not-enabled after opt-inConfirm native rebuild picked up the flag
messaging/token-api-disabledMigrate remaining token call sites off token APIs

3. Validate

bash
# After native rebuild with the flag on:
# - register() / onRegistered deliver a FID
# - getToken / deleteToken reject and onTokenRefresh throws with messaging/token-api-disabled
# With the flag off, register / unregister reject and onRegistered / onUnregistered throw with messaging/installation-id-not-enabled

Confirm your backend receives and uses the FID for device targeting after migration.