我想知道是否有其他人有同样的问题,我正在使用Firebase电子邮件和密码登录项目,一切正常,除了验证电子邮件,这里的代码有没有其他人有这个问题?它属于Google吗?或者是我做错了什么?因为signUp方法工作正常,用户按下Register按钮后会创建用户,但是从未调用过sendVerificationEmail方法
这是signUp方法,其中包含 sendVerificationEmail 方法:
if (checkSignUpFormFields()) {
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(LaunchActivity.this, "Your account successfully created", Toast.LENGTH_SHORT).show();
sendVerificationEmail();
FirebaseAuth.getInstance().signOut();
} else {
Toast.makeText(LaunchActivity.this, "something went wrong, Check your information",
Toast.LENGTH_SHORT).show();
updateUI(null);
}
}
});
}
这是发送验证方法的方法:
private void sendVerificationEmail(){
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null){
user.sendEmailVerification().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
Toast.makeText(LaunchActivity.this, "Verification Email has been sent.", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(LaunchActivity.this, "Something went wrong!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
1 回答
大约一个小时前就已经制作了它,它只需要花费一个多小时左右的时间,而且必须是 Googles 问题 .