android - When do fcm refresh tokens created -


i'm new android , looking on firebase.in app multiple mobile numbers can logged in. doing deleting current token by

firebaseinstanceid.getinstance().deleteinstanceid(); 

and after when log in new number, new token gets generated.

so question in event triggers token regeneration event. 1 more thing above code line should have run on thread (other main thread) work

this service used getting firebase token

    public class fcminstanceidlistenerservice extends firebaseinstanceidservice { appsharedpreferences appsharedpreferences;     @override     public void oncreate() {         super.oncreate();         string currenttoken = firebaseinstanceid.getinstance().gettoken();         if (currenttoken!=null){             intent intent = new intent("device_id");             localbroadcastmanager.getinstance(this).sendbroadcast(intent);             log.d("token", "refreshed token: " + currenttoken);             appsharedpreferences.putstring("device_id",currenttoken);         }         else {                ontokenrefresh();                 }        }      public fcminstanceidlistenerservice() {          appsharedpreferences=appsharedpreferences.getsharedprefinstance(this);         // prefmanager = prefmanager.getinstance(this);     }      @override     public void ontokenrefresh() {         super.ontokenrefresh();         string refreshedtoken = firebaseinstanceid.getinstance().gettoken();         intent intent = new intent("device_id");         localbroadcastmanager.getinstance(this).sendbroadcast(intent);         log.d("token", "refreshed token: " + refreshedtoken);         appsharedpreferences.putstring("device_id",refreshedtoken);         // prefmanager.putstring(prefrenceconstants.key_device_id, refreshedtoken);      }  } 

from developer site:

ontokenrefresh() called when system determines tokens need refreshed. application should call gettoken() , send tokens application servers.

this not called frequently, needed key rotation , handle instance id changes due to:

  • app deletes instance id

  • app restored on new device

  • user uninstalls/reinstall app

  • user clears app data

the system throttle refresh event across devices avoid overloading application servers token updates.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -