Registration Token in Push Notifications: What It Is, How to Get and Update

Author: IT Sectr Published: 2026-03-21 Reading time: 8 min

Registration Token is a unique device identifier that Firebase Cloud Messaging (FCM) uses to deliver push notifications. Each app on each device receives its own token, without which sending notifications is impossible. According to Firebase, 2025, the Registration Token is automatically generated when the app is first launched and may change under certain conditions.

Key Takeaways

  • Registration Token is a string that identifies an app instance on a specific device for FCM.
  • The token is generated automatically on first launch or after clearing app data.
  • FCM uses the token to route push notifications to the correct device.
  • The token may change — the app must subscribe to updates via onNewToken.
  • To send notifications, the server must store current tokens for all devices.

What Is a Registration Token

Registration Token is a unique string up to 4096 characters long that Firebase Cloud Messaging assigns to each app instance. The token is formed based on the application ID, device ID, and the Google account on the device.

Token Structure and Purpose

A Registration Token consists of a random sequence of characters encoded in Base64 format. FCM uses this token as a delivery address — the server sends a notification to the token, and FCM routes it to the specific device. Without a token, it is impossible to address a push notification to a specific user.

Differences from Other Identifiers

A Registration Token should not be confused with a Device ID (IMEI) or Advertising ID. Device ID is a hardware identifier of the device, while Advertising ID is used for advertising purposes. Registration Token is tied to the combination of app and device, and one device can have multiple tokens for different apps.

IdentifierPurposeMutability
Registration TokenFCM push notification deliveryMay change
Device ID (IMEI)Hardware identificationPermanent
Advertising IDTargeted advertisingCan be reset
Instance IDLegacy Firebase mechanismChanged on deletion

When a Token Is Considered Invalid

FCM may consider a Registration Token invalid in several situations. If the app is removed from the device, the token is automatically revoked. When restoring data from a backup on a new device, the old token stops working. Firebase also returns a UNREGISTERED status when attempting to send a notification to an outdated token.

How FCM Assigns a Registration Token

Firebase Cloud Messaging generates a Registration Token when the app is first launched and the getToken() method is called. The process includes verifying Google Play Services credentials and registering the app in the Firebase infrastructure.

Device Registration Process

When a device runs an app with the integrated FCM SDK for the first time, the following occurs. The Firebase SDK checks for Google Play Services on the device. The SDK then sends a request to Firebase servers, passing the application ID and device information. The Firebase server creates a new token and returns it to the app.

FCM Internal Mechanics

FCM uses an architecture based on long-lived connections. After receiving a Registration Token, the device establishes a persistent connection to Firebase servers via the STOMP protocol on Android or the APNs channel on iOS. When the server sends a notification to the token, FCM finds the device by the token and delivers the payload.

Token Regeneration Conditions

A Registration Token may be regenerated by FCM in the following cases. When restoring an app from a backup on a new device. When deleting and reinstalling the app. When clearing app data through system settings. When signing into a different Google account on the device. Firebase recommends always handling the onNewToken callback to track changes.

Getting a Registration Token on Android

On Android, the Registration Token is obtained through the Firebase Messaging SDK. The process differs for different SDK versions — newer versions use the FirebaseInstallations API instead of the deprecated FirebaseInstanceId.

Modern Approach via FirebaseInstallations

Starting with Firebase SDK version 21.0.0, the getToken() method is called through FirebaseMessaging. This approach automatically manages the token lifecycle and subscribes to its updates.

kotlin
class MyFirebaseMessagingService : FirebaseMessagingService() {

    override fun onNewToken(token: String) {
        sendRegistrationToServer(token)
    }

    private fun sendRegistrationToServer(token: String) {
        // Sending token to server
        Log.d("FCM", "New token: $token")
    }

    init {
        FirebaseMessaging.getInstance()
            .getToken()
            .addOnCompleteListener { task ->
                if (!task.isSuccessful) {
                    Log.w("FCM", "Fetching FCM token failed")
                    return@addOnCompleteListener
                }
                val token = task.result
                sendRegistrationToServer(token)
            }
    }
}

Handling the Token in Activity or ViewModel

In some scenarios, the token is needed not in the service but directly in an Activity or ViewModel. In this case, getToken() can be called at a convenient point in the app lifecycle. It is important not to call this method from the main thread without handling asynchrony.

kotlin
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        getFCMToken()
    }

    private fun getFCMToken() {
        FirebaseMessaging.getInstance().getToken()
            .addOnCompleteListener { task ->
                if (task.isSuccessful) {
                    val token = task.result
                    Log.d("FCM", "Token: $token")
                }
            }
    }
}

Legacy FirebaseInstanceId Method

In older versions of the Firebase SDK (before version 20.x), the token was obtained via FirebaseInstanceId.getInstance().getToken(). This method is marked as deprecated and is not recommended for use in new projects. Developers maintaining legacy code should migrate to the FirebaseInstallations API.

Getting a Registration Token on iOS

On iOS, the process of obtaining a Registration Token differs architecturally — FCM works through the Apple Push Notification service (APNs). The Firebase SDK receives a unique device token from APNs, converts it to FCM format, and passes it to the app.

APNs Setup and Token Retrieval

To use FCM on iOS, you must configure an APNs certificate or key in the Firebase console. The app must request notification permission via UNUserNotificationCenter. After receiving the APNs token, the Firebase SDK automatically generates the Registration Token.

swift
import FirebaseMessaging
import UserNotifications

class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(
        application: UIApplication,
        didFinishLaunchingWithOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        FirebaseApp.configure()
        Messaging.messaging().delegate = self
        requestNotificationAuthorization()
        return true
    }

    private func requestNotificationAuthorization() {
        let center = UNUserNotificationCenter.current()
        center.requestAuthorization(options: [.alert, .sound, .badge])
    }
}

extension AppDelegate: MessagingDelegate {
    func messaging(
        messaging: Messaging,
        didReceiveRegistrationToken fcmToken: String?
    ) {
        Log.d("FCM", "Token: \(fcmToken ?? "")")
        sendTokenToServer(token: fcmToken)
    }
}

Differences Between iOS and Android Tokens

The Registration Token on iOS is smaller compared to the Android token, as it is based on the APNs device token. The Firebase SDK automatically updates the FCM token when the APNs token changes, which happens when restoring a device from a backup or reinstalling the app.

Updating and Managing Registration Tokens

Managing the lifecycle of a Registration Token is critically important for reliable push notification delivery. If the server stores an outdated token, notifications will not be delivered, and Firebase will return a UNREGISTERED error.

Monitoring Token Changes

The Firebase SDK provides two mechanisms for tracking token changes. On Android, the onNewToken callback in FirebaseMessagingService is used. On iOS, the messaging:didReceiveRegistrationToken delegate is used. Both are called each time the token is updated.

kotlin
// Saving token to SharedPreferences and sending to server
class TokenManager(private val context: Context) {

    companion object {
        private const val PREFS_TOKEN_KEY = "fcm_registration_token"
    }

    fun saveToken(token: String) {
        val prefs = PreferenceManager
            .getDefaultSharedPreferences(context)
        prefs.edit().putString(PREFS_TOKEN_KEY, token).apply()
    }

    fun getSavedToken(): String? {
        val prefs = PreferenceManager
            .getDefaultSharedPreferences(context)
        return prefs.getString(PREFS_TOKEN_KEY, null)
    }
}

Server-Side Token Storage Strategy

The server must store the Registration Token in association with the user identifier. When the token is updated, the client sends the new token to the server, and the server replaces the old one. It is recommended to keep a token history: if a notification is not delivered to the new token, the old one can be tried.

Error Handling When Working with Tokens

Firebase may return a token retrieval error in several cases. If Google Play Services are missing on the device, the token will not be obtained. If the request quota to FCM is exceeded, an exponential backoff should be implemented for retries. If the token expires, the SDK automatically requests a new one.

SituationResultDeveloper Action
App removalToken is revokedDelete token from database
Backup restorationNew tokenUpdate in database
Google Play Services resetToken regeneratedHandle onNewToken
Token expirationAutomatic updateSubscribe to updates

Frequently Asked Questions

What should I do if the Registration Token is not received?

Check that Google Play Services is available on the device, verify the google-services.json file, and check the Firebase SDK version. Make sure the app has internet permission.

How often does the Registration Token change?

The token may change when uninstalling and reinstalling the app, clearing data, restoring from a backup, or signing into a different Google account. There is no fixed time interval.

Can one device have multiple Registration Tokens?

Yes, each app on the device receives its own FCM token. If a device has three apps with Firebase, each will have its own unique Registration Token.

How can I check if a Registration Token is still valid?

Send a test notification through the Firebase console or the FCM HTTP API. If the token is invalid, the API will return a UNREGISTERED or NOT_FOUND error.

Is it safe to store a Registration Token on the server?

A Registration Token is not a secret key, but its leak allows sending notifications to the user's device. Store tokens in a secure database and use HTTPS for transmission.

Summary

  • Registration Token is a required element for delivering push notifications via Firebase Cloud Messaging.
  • The token is generated automatically on first launch of an app with the FCM SDK.
  • On Android, the token is obtained via FirebaseMessaging.getInstance().getToken().
  • On iOS, the token is based on the APNs device token and is passed via the MessagingDelegate.
  • The token may change — the app must handle the onNewToken callback.
  • The server must store current tokens and delete outdated ones when an UNREGISTERED error occurs.
  • For reliable delivery, implement token change monitoring and a retry mechanism for failures.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also