无法将Firebase数据库集成到我的应用中

时间:2019-09-24 11:21:47

标签: java android firebase-realtime-database

使用Firebase电话身份验证创建应用程序。它确实运行良好,但是现在我已经为帐户创建了一个数据库(使用Firebase实时数据库),并且停止了工作。这是我的代码和一些屏幕截图。希望对您有帮助

private void signInWithCredential(PhoneAuthCredential credential) {
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {

                        FirebaseUser user = task.getResult().getUser();

                         String number = user.getPhoneNumber();

                        String uid = user.getUid();

                        HashMap<Object, String> hashMap = new HashMap<>();

                        hashMap.put("number", number);
                        hashMap.put("uid", uid);
                        hashMap.put("name", "");
                        hashMap.put("email", "");
                        hashMap.put("image", "");

                        FirebaseDatabase database = FirebaseDatabase.getInstance();

                        DatabaseReference reference = database.getReference("Users");
                        reference.child(uid).setValue(hashMap);

                        Intent intent = new Intent(VerifyPhoneActivity.this, ProfileActivity.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

                        startActivity(intent);


                    } else {
                        Toast.makeText(VerifyPhoneActivity.this, task.getException().getMessage(), Toast.LENGTH_LONG).show();
                    }
                }
            });
}

screenshot of my databse rules Logcat

error section

0 个答案:

没有答案