You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation says that onNewToken is called upon the first app start, but that's not true.
It's called only when a new token is needed, so if you add ParsePush on an application that already implemented firebase cloud messaging, this method will not be called so ParseFCM.register(token); in ParseFirebaseMessagingService it's not called too.
To fix this we can simply add this on application onCreate: FirebaseMessaging.getInstance().getToken().addOnCompleteListener(task -> { if (!task.isSuccessful()) { return; } String token = task.getResult(); ParseFCM.register(token); });
Can be this implemented some where in Parse Push library?
The text was updated successfully, but these errors were encountered:
This is the FCM module issue which now is an optional module. I was thinking to resolve this when Parse initialize but...
Looking at the source of the FCM module and Firebase documentation, everything is implemented as expected. Firebase also mentioned on which cases the token is refreshed and onNewToken is called.
@Azaratur what you did there is a fix for your case and maybe can help others. I also used it before on some of my projects, but I found that for me occurs only when I develop and the way to fix it is to uninstall the app first and clear the data. If you have more general idea to improve the FCM token retrieval feel free to open a PR.
Documentation says that onNewToken is called upon the first app start, but that's not true.
It's called only when a new token is needed, so if you add ParsePush on an application that already implemented firebase cloud messaging, this method will not be called so ParseFCM.register(token); in ParseFirebaseMessagingService it's not called too.
To fix this we can simply add this on application onCreate:
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(task -> { if (!task.isSuccessful()) { return; } String token = task.getResult(); ParseFCM.register(token); });
Can be this implemented some where in Parse Push library?
The text was updated successfully, but these errors were encountered: