Cloud Messaging Device Token Expiry? #6351
-
Docs say: "Firebase Cloud Messaging tokens are associated with the instance of the installed app. By default, only token expiration or uninstalling/reinstalling the app will generate a fresh token." However, I cannot find anywhere where it states how long an FCM device token is valid before it expires. Could anyone clarify? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think the real idea here is "what are best practices for token management", because expiry isn't the important part. You must store tokens on the server for them to be useful for device targeting so you always have to manage token freshness/staleness. https://search.brave.com/search?q=firebase+device+token+expiration+time https://stackoverflow.com/questions/41982619/when-does-a-fcm-token-expire https://firebase.google.com/docs/cloud-messaging/android/client#sample-register Here's the token management guide: https://firebase.google.com/docs/cloud-messaging/manage-tokens And here's how you can listen for async token changes while the app is running, in combo with fetching the token on startup as a default best practice And this https://rnfirebase.io/reference/messaging#onTokenRefresh Basically token expiry is sort of un-interesting from a token management perspective, it may never expire (it's a JWT, you can peel it apart and check expiry if you like?) but it may change asynchronously for instance if data is cleared on device, so you should always fetch on startup + listen to onTokenRefresh and follow best practices for token management such that tokens that fail while in use on server are removed. Hopefully that helps? |
Beta Was this translation helpful? Give feedback.
I think the real idea here is "what are best practices for token management", because expiry isn't the important part. You must store tokens on the server for them to be useful for device targeting so you always have to manage token freshness/staleness.
https://search.brave.com/search?q=firebase+device+token+expiration+time
https://stackoverflow.com/questions/41982619/when-does-a-fcm-token-expire
https://firebase.google.com/docs/cloud-messaging/android/client#sample-register
Here's the token management guide:
https://firebase.google.com/docs/cloud-messaging/manage-tokens
And here's how you can listen for async token changes while the app is running, in combo with fetching the token on sta…