chemerisuk / cordova-plugin-firebase-messaging

Cordova plugin for Firebase Cloud Messaging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method onTokenRefresh does not work

Antontsyk opened this issue · comments

Hello.
I use you plugin and use method onTokenRefresh for track uninstall in appsflyer, but does not work

example:
window.cordova.plugins.firebase.messaging.onTokenRefresh(() => {
window.cordova.plugins.firebase.messaging.getToken().then((token) => {
window.plugins.appsFlyer.updateServerUninstallToken(token);
});
});

@Antontsyk you need to add additional firebaseMessaging.getToken because onTokenRefresh callback is triggered only on token change:

firebaseMessaging.getToken().then((token) => {
   window.plugins.appsFlyer.updateServerUninstallToken(token);
});

firebaseMessaging.onTokenRefresh(() => {
    firebaseMessaging.getToken().then((token) => {
        window.plugins.appsFlyer.updateServerUninstallToken(token);
    });
});

thanks, all working!