private FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
firebaseAuth=FirebaseAuth.getInstance();
firebaseAuth.addAuthStateListener(new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
if(firebaseAuth.getCurrentUser()!=null){
Log.d("user","a user has logged in"); //tried calling sendEmailVerification here
}
else{
Log.d("user","user has logged out");
}
}
});
.........
}
public void signUpButtonClick(View view){
//after making sure that the user entered email and password
firebaseAuth.createUserWithEmailAndPassword(mailEntry,passwordEntry).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("task","success"); //tried calling sendEmailVerification here
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
e.printStackTrace();
}
});
}
创建新用户可以正常工作,但调用sendEmailVerification()
无效,邮件无法发送。需要帮助。