你们知道问题是什么吗?我需要Firebase在用户注册时立即发送电子邮件验证。这种逻辑是否有效,如果我是这样,我会错过什么? Firebase正在很好地注册用户。
switch (v.getId()) {
case R.id.bRegister:
firebaseAuth.createUserWithEmailAndPassword(schoolEmail, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
//save username, state, school
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
user.sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
finish();
Toast.makeText(Register.this, "Registered Successfully. Check your email", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), VerifyEmail.class));
}
}
});
if (firebaseAuth.getCurrentUser() != null) {
finish();
startActivity(new Intent(getApplicationContext(), CampusMe.class)); //later change to a page that will let the user know they need to verify email.
}
} else {
Toast.makeText(Register.this, "Could not Register User. Try Again", Toast.LENGTH_SHORT).show();
}
}
});
break;