app/src/main/java/fr/neamar/lolgamedata/service/TokenRefreshedService.java
/**
     * Called if InstanceID token is updated. This may occur if the security of
     * the previous token had been compromised. Note that this is also called
     * when the InstanceID token is initially generated, so this is where
     * you retrieve the token.
     */
Called if InstanceID token is updated. This may occur if the security of
the previous token had been compromised. Note that this is also called
when the InstanceID token is initially generated, so this is where
you retrieve the token.
Called if InstanceID token is updated . This may occur if the security of the previous token had been compromised . Note that this is also called when the InstanceID token is initially generated so this is where you retrieve the token .
@Override
    public void onTokenRefresh() {
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);
        try {
            Intent intent = new Intent(this, SyncTokenService.class);
            this.startService(intent);
        }
        catch(IllegalStateException e) {
            PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(TOKEN_UPDATE_REQUIRED, true).apply();
        }
    }
@ Override public void onTokenRefresh ( ) { String refreshedToken = FirebaseInstanceId . getInstance ( ) . getToken ( ) ; Log . d ( TAG , "Refreshed token: " + refreshedToken ) ; try { Intent intent = new Intent ( this , SyncTokenService . class ) ; this . startService ( intent ) ; } catch ( IllegalStateException e ) { PreferenceManager . getDefaultSharedPreferences ( this ) . edit ( ) . putBoolean ( TOKEN_UPDATE_REQUIRED , true ) . apply ( ) ; } }
Called if InstanceID token is updated.
Called if InstanceID token is updated .
// Get updated InstanceID token. // Resync with server // This will happen when the token changes remotely, but the app isn't in the foreground yet.