Home / Companies / Firebase / Blog / Post Details
Content Deep Dive

Managing Cloud Messaging Tokens

Blog post from Firebase

Post Details
Company
Date Published
Author
Andrea Wu
Word Count
1,712
Company Posts That Month
2
Language
English
Hacker News Points
-
Post removed?
No
Summary

Firebase Cloud Messaging registration tokens identify individual app instances and should be generated, retrieved, stored, refreshed, and removed carefully to support reliable targeted notifications and accurate delivery reporting. On Android, apps can handle newly generated or changed tokens through `onNewToken()`, retrieve the current token through the FCM SDK at startup, and store the token with a server-side timestamp, using Firestore or a custom backend, typically keyed to an authenticated user. Tokens can change after reinstalls, restored devices, cleared app data, hardware failures, or FCM security operations, so the app should compare and update stored values when opened and periodically refresh them, such as monthly, with WorkManager. Server-side message sends should delete tokens when valid requests return invalid-token errors such as `UNREGISTERED` or, when the payload is known to be valid, `INVALID_ARGUMENT`. Finally, scheduled backend jobs can prune tokens whose timestamps exceed a chosen staleness period, with roughly 60 days suggested, helping ensure messages target active devices while limiting obsolete token records.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.