Firebase Flashlight Update

The Firebase documentation clearly states that the FirebaseInstanceIdService must be implemented to access the updated token and that manual registration is no longer required, since the library takes care of all the processes.

The problem is that onTokenRefresh is called only once, and if something went wrong while transferring it to my server, the application must wait until the next update or complete a uninstall / reinstall.

Can I apply the same logic as previous GCM implementations? That is, every time I launch my application, I use a token using FirebaseInstanceId.getInstance().getToken() , and send it to my server, not caring if it has already been sent. The same thing is done in onTokenRefresh .

Does this approach have any kind of error?

+7
android token firebase google-cloud-messaging
source share
2 answers

What am I suggesting for the first time that you force TOKEN to store it locally (maybe in general privilege) and

make one flag, initialize it as false

and then try sending TOKEN to your server that it sent by successfully changing the ti true flag, and you do not need to send it again.

+3
source share

Also, it seems you can call this function from outside the service

FirebaseInstanceId.getInstance().getToken();

+10
source share

All Articles