Skip to content Skip to sidebar Skip to footer

How To Release Firebase Cloud Messaging Token When Android User Logs Out?

I'm developing an Android app that involves Firebase Cloud Messaging. My messages consist of notifications with data payload, and are sent to the Firebase server by means of a node

Solution 1:

The Firebase Instance ID token identifies an installed instance of your application. Trying to change its meaning is a recipe for headaches.

You should not use it to identify a user. So unless the user uninstalls the app (in which case the token is automatically deleted), you should not try to delete the token when the user logs out.

If you want to stop sending notifications to a user-on-a-device once they sign out, you should track that in your database: "user A is using token B".

UserTokens
  UserA: "tokenB"

Then you can clear that data when the user signs out: "user A is no longer using a token".

UserTokens
  UserA: ""

Then when user B signs in to the same app on the same device, they'd get the same token:

UserTokens
  UserB: "tokenB"

Post a Comment for "How To Release Firebase Cloud Messaging Token When Android User Logs Out?"