On Android, FCM (Firebase Cloud Messaging) token is refreshed when-

  • App deletes Instance ID
  • App is restored on a new device
  • User uninstalls/reinstall the app
  • User clears app data

Here's a way to get refreshed token and store to Shared Preferences-

public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);