Reputation: 12385
I'm reading through FCM token management best practices in the documentation (https://firebase.google.com/docs/cloud-messaging/manage-tokens) and have the following questions.
On initial startup of your app, the FCM SDK generates a registration token for the client app instance... your app should retrieve this token at initial startup and save it to your app server alongside a timestamp.
Is the recommendation here to handle the token on app launch or just the first time the app is launched on install? Because I can't imagine given how many server interactions there are in the typical life of a client process that we wouldn't just update the token every time the app is launched and call it a day instead of creating additional tasks to keep these tokens fresh.
We recommend that you periodically retrieve and update all registration tokens on your server.
Is the recommendation here to null
stale tokens?
We recommend that you periodically retrieve and update all registration tokens on your server. This requires you to add server logic to update the token’s timestamp at regular intervals, regardless of whether or not the token has changed.
I don't understand what this means. Is the recommendation here to task the server with updating a token's timestamp? What does this accomplish? And is the server capable of generating a token for a client?
Upvotes: 5
Views: 3708
Reputation: 41
According to the docs, as I understand, you have to :
On client side :
On server side:
Upvotes: 2
Reputation: 1286
The token is generated only when you first launch the app after install, and in some reset events. So your token will stay mostly the same, it won't change in every app launch. The timestamp is what the server will check. Maybe this will help:
Now, this is where it gets hazy. As far as I understand, the server should signal the app in some way to get the token again (even if it is unchanged) to refresh the token in the server database and then refresh the timestamp.
Upvotes: 0