chemerisuk / cordova-plugin-firebase-messaging

Cordova plugin for Firebase Cloud Messaging
MIT License
164 stars 160 forks source link

Method onTokenRefresh does not work #193

Closed Antontsyk closed 3 years ago

Antontsyk commented 3 years ago

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); }); });

chemerisuk commented 3 years ago

@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);
    });
});
Antontsyk commented 3 years ago

thanks, all working!