- Mastering Firebase for Android Development
- Ashok Kumar S
- 107字
- 2021-06-18 18:49:18
Forgot password
When the user has forgotten their password, he can receive a password reset email using the sendPasswordResetEmail method with a string email address as a parameter:
FirebaseAuth auth = FirebaseAuth.getInstance();
String emailAddress = "vinisha@krishna.com";
auth.sendPasswordResetEmail(emailAddress)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Email sent.");
}
}
});
We can customize the email template and language in the reset mail as well. Once the user receives a mail, he will be able to set the password again. We will explore how to customize the email template in a later section of the chapter.