Firebase不会接收电子邮件/密码身份验证

问题描述 投票:0回答:1

我的代码完美运行,我没有错误,我通过调试运行应用程序,没有任何显示。所以我已经检查过我是否拥有最新的firebase依赖项并且我已经更新了Google Play服务但由于某些原因我的应用程序不会将用户注册到Firebase。

EditText registerEmail, registerPassword;

private FirebaseAuth mAuth;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    registerEmail = (EditText) findViewById(R.id.registerEmail);
    registerPassword = (EditText) findViewById(R.id.registerPassword);

    mAuth = FirebaseAuth.getInstance();

    findViewById(R.id.registerButton).setOnClickListener(this);
}

private void registerUser() {
    String email = registerEmail.getText().toString().trim();
    String password = registerPassword.getText().toString().trim();

    if(email.isEmpty()) {
        registerEmail.setError("Email is required");
        registerEmail.requestFocus();
        return;
    }
    if(!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
        registerEmail.setError("Enter a valid email");
        registerEmail.requestFocus();
        return;
    }
    if(password.isEmpty()) {
        registerPassword.setError("Password is required");
        registerPassword.requestFocus();
        return;
    }
    if(password.length() < 8) {
        registerPassword.setError("Minimum 8 characters required");
        registerPassword.requestFocus();
        return;
    }

    mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if(task.isSuccessful()) {
                Toast.makeText(getApplicationContext(), "successful", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), "not successful", Toast.LENGTH_SHORT).show();
            }
        }
    });

}

@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.registerButton:
            registerUser();
            //startActivity(new Intent(this, MainActivity.class));

            break;
        case R.id.loginTextView:

            startActivity(new Intent(this, Login.class));

            break;
    }
}

我得到了“不成功”的消息所以问题必须在这里mAuth.createUserWithEmailAndPassword()。先感谢您。

java android firebase firebase-authentication
1个回答
0
投票

你得到的错误是非常误导的,在线寻找解决方案我发现无数人在努力解决这个问题,但没有人提到启用Google Identity Toolkit API来解决这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.