3

I am sending notification to my web application from FCM. It is working fine.

Now I have to do following two things :

  1. I have to refresh the token each time when user visit to the portal
  2. How user can un-subscribe from notification

I have to do the above two things using javascript or jquery.

   // Callback fired if Instance ID token is updated.
    messaging.onTokenRefresh(function() {
      messaging.getToken().then(function(refreshedToken) {
        console.log('Token refreshed.');
        // Indicate that the new Instance ID token has not yet been sent to the
        // app server.
         setTokenSentToServer(false);
       // Send Instance ID token to app server.
      sendTokenToServer(refreshedToken);
      // ...
    }).catch(function(err) {
    console.log('Unable to retrieve refreshed token ', err);
    showToken('Unable to retrieve refreshed token ', err);
  });
  });

This method never triggered at all.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

0 Answers0