FCM Token is invalidating for chrome frequently

1k views Asked by At

FCM Token is invalidating for chrome frequently, But it's working for firefox. I have implemented onTokenRefresh() callback. Here is my implementation

messaging.onTokenRefresh(function () { console.log("refresh token called(webpush)"); messaging.getToken().then(function (refreshedToken) { console.log('Token refreshed.', refreshedToken); // post data to db }); });

How to check that above implementation is working properly. Not able to save the refreshed token to our DB.

1

There are 1 answers

3
Matt Gaunt On BEST ANSWER

At the moment the on token refresh callback is not used. But it will be in a future update.

If you wanted to check your logic you could just pull out the callback and call i directly

const onRefreshCb = function() {
  messaging.getToken()......
};

messaging.onTokenRefresh(onRefreshCb);

To test you'd just call onRefreshCb() to test out your logic, using deleteToken if you wanted to ensure you would get a new token.