gpt4 book ai didi

java - 注册后如何发送验证邮件

转载 作者:行者123 更新时间:2023-12-02 11:40:04 24 4
gpt4 key购买 nike

我使用 Firebase 进行用户注册,但我找不到任何在注册后发送验证电子邮件的方法。

auth = FirebaseAuth.getInstance();

auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(SignupActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Toast.makeText(SignupActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Toast.makeText(SignupActivity.this, "Authentication failed." + task.getException(),
Toast.LENGTH_SHORT).show();
} else {
FirebaseUser user = auth.getCurrentUser()

startActivity(new Intent(SignupActivity.this, MainActivity.class));
finish();
}
}
});

最佳答案

您可以使用 sendEmailVerification 方法向用户发送地址验证电子邮件。例如:

FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();

user.sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Email sent.");
}
}
});

更多信息请点击:https://firebase.google.com/docs/auth/android/manage-users

关于java - 注册后如何发送验证邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48651923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com