Firebase observeSingleEvent not invoking callback function ios

1.5k views Asked by At

I have a situation in which my Firebase reference is not invoking the callback for observeSingleEvent.

 let uid = FIRAuth.auth()?.currentUser?.uid

 FIRDatabase.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: { (snapShot) in                    
           //code here not called
        }) { (error) in
           //code here not called either
        }

In my case it appears the uid property which is coming from FIRAuth.auth()?.currentUser?.uid is somehow being cached from a previous app installation when I'm switching between Firebase environments (building with different dev and staging .plist files.)

However, if I just add a random non existing string in place of uid the callback occurs as expected with an empty snapshot for a missing reference node.

I believe it's relevant to mention that I'm using synced Firebase references with persistanceEnabled = true.

I'm in a situation where I'm switching between environments and my app is hanging because promises are not being fulfilled or rejected because the results of by observeSingleEvent method call are never completing.

0

There are 0 answers