Firebase single-user event listener does not return

I have been using Firebase in my application successfully for several months. I just finished updating to use version 9.0.0, and I still have one problem that I cannot understand.

In my MainActivity onCreate function, I check if the user is logged into Firebase. If the user is logged in, I try to retrieve the user object that I have in my database.

This is the only instance of the application in which I am having problems with this. I checked that the user is logged in and the DatabaseReference pointed to the correct URL.

A DatabaseReference is created and the listener is added, but nothing on the listener never fires ...

    FirebaseAuth auth = FirebaseAuth.getInstance();

    if (auth != null && auth.getCurrentUser() != null) {
        DatabaseReference userRef = FirebaseDatabase.getInstance().getReference().child(USERS).child(auth.getCurrentUser().getUid());
        userRef.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                // Logic for success is here...
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

                // Logic for failure is here...
            }
        });
    }

Any ideas on what I'm doing wrong?

+4
2

, Firebase Auth . SHA-1 Firebase.

Firebase Console. "". ​​ SHA-1.

SHA-1 , . , google-services.json Android Studio , .

, Firebase, , .

+4

,

{
    "rules": {
        ".read": "auth == null",
        ".write": "auth == null"  
    }
}

, .

0

All Articles