Skip to content Skip to sidebar Skip to footer

How To Delete Firebase Cloud Messaging Token When User Log-out Of The React Native Application?

I use React Native FCM for messaging, and when the user logs out the application I want to delete the FCM token so that the user doesn't get Notified again. Below is my code for lo

Solution 1:

Simply add below given code in your logout function.

firebase.messaging().deleteToken()

Solution 2:

await firebase.messaging().deleteToken();

is the solution.

BUT, if you get the same token even after deleting, install the npm package react-native-restart, and do the below step to get a new token

messaging()
            .deleteToken(undefined,'*')
            .then(() => {
                RNRestart.Restart();

Post a Comment for "How To Delete Firebase Cloud Messaging Token When User Log-out Of The React Native Application?"