Firebase发送验证电子邮件不起作用

时间:2017-12-01 21:06:02

标签: android firebase firebase-authentication

我想知道是否有其他人遇到同样的问题,我正在使用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 个答案:

答案 0 :(得分:0)

Firebase本身存在一些问题,我收到了一封电子邮件,我在大约一小时前就进行了注册,它只花了一个多小时左右的时间,而且必须谷歌问题