I am using Firebase Messaging token for sending notifications to users from Firebase Function. But when the user decides to log out, I have to change this token for the new user. The only way that I have found to achieve this is to delete FirebaseInstanceId
which I don't think is a good practice. What is the correct way to do it?
The method that I use:
public void disableFCM(){
FirebaseMessaging.getInstance().setAutoInitEnabled(false);
new Thread() {
@Override
public void run() {
try {
FirebaseInstanceId.getInstance().deleteInstanceId();
} catch (IOException e) {
Toast.makeText(MainActivity.this, e.getMessage() , Toast.LENGTH_SHORT).show();;
}
}
}.start();
}