这是我尝试使用唯一用户 ID 更新数据的部分。但它总是显示注册失败,即使身份验证部分正在工作。
mAuth.createUserWithEmailAndPassword(email,password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful())
{
user user=new user(
nameOfUser,
email,
phNo
);
//Toast.makeText(Register_User.this, "Working", Toast.LENGTH_SHORT).show();
mData.getReference("Users")
.child(Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getUid())
.push().setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
progressBar.setVisibility(View.GONE);
Toast.makeText(Register_User.this, "Upto here", Toast.LENGTH_LONG).show();
if (task.isSuccessful()) {
Toast.makeText(Register_User.this, "Successfully Registered", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Register_User.this, "Failed to Registered", Toast.LENGTH_SHORT).show();
}
}
});
}
else if (task.getException() instanceof FirebaseAuthUserCollisionException) {
progressBar.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "You are already registered", Toast.LENGTH_SHORT).show();
}
}
});
回首忆惘然
相关分类