How to Get the FCM Device Registration Token
Platform-specific guide to retrieving the FCM registration token from Android, iOS, and web apps for push notification testing.
Last updated: May 2026

Android (Kotlin)
Ensure Firebase is initialized and google-services.json is in your app module. Request notification permission on Android 13+. Call FirebaseMessaging.getInstance().token.addOnCompleteListener and log the result.

FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("FCM", "Token: ${task.result}")
}
}iOS (Swift)
Enable Push Notifications and Background Modes → Remote notifications in Xcode. Upload your APNs authentication key in Firebase Console. Call Messaging.messaging().token and print the token after permission is granted.

Web (JavaScript)
Initialize Firebase, request notification permission with Notification.requestPermission(), then use getToken(messaging, { vapidKey: "..." }) from firebase/messaging. The VAPID key is in Firebase Console → Cloud Messaging → Web configuration.
Token lifecycle
Tokens refresh when the app is restored on a new device, when the user clears app data, or when FCM invalidates a token. Subscribe to onNewToken (Android) or messaging(_:didReceiveRegistrationToken:) (iOS) to keep your backend updated.
Continue with our complete testing guide or open the FCM tester to send a notification now.
Ready to test? Open the FCM tester · Browse all guides