4
 this.onTokenRefreshListener = firebase
.messaging()
.onTokenRefresh(fcmToken => {
  // Process your token as required
  console.log("fcmToken onTokenRefresh", fcmToken);
  console.log("fcmToken onTokenRefresh client", client);
  // await AsyncStorage.setItem("fcmToken", fcmToken);
  sendDeviceTokenToServerOnTokenRefresh(client, fcmToken);
  console.log("fcmToken onTokenRefresh after", fcmToken);
});

This has been used in componentDidMount. OnTokenRefresh is not fired, I have tested many time by generating new token by deleting the app cache. new token is available if i use firebase.messaging().getToken(). But onTokenRefresh seems to be inactive. I could be a possibility the token has been generated much before the call of componentDidMount. Let me know if anyone have faced the same issue.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
shaktisinghmoyal
  • 312
  • 1
  • 5
  • 14

0 Answers0