Background:
I have an application in which new users fill out a registration form (consisting of a username, email and password) to register for an account. When a new user submits a form, the application checks its Firebase database to see if the username has already been executed. The problem here is that observeSingleEvent(of:with:) does not receive the latest data. When I update data directly from the Firebase console, the changes are not reflected in the observeSingleEvent(of:with:) returned results. Even between application reloads, new data changes are not returned.
The only thing I saw in this question is here . The user says that when using observeSingleEvent(of:with:) persistence is not supported. But my perseverance is disabled. Also, I set keepSynced() in the FIRDatabase instance to false (and I also tried true). No luck with the setup.
Here is an example of what I'm trying:
let usersDatabaseReference = FIRDatabase.database().reference().child("users") usersDatabaseReference.keepSynced(false) // Query the database to see if the username is available // The user with the username "mark" was removed from the database via the Firebase console let username = "mark" // This user used to exist in the database (and was previously added through the app). usersDatabaseReference.child(username).observeSingleEvent(of: .value, with: { (snapshot) in ... } )
The above block of code should return the latest data (one where the user mark "should not exist").
I am wondering if someone else ran into this problem or if anyone has any possible solutions.
Note. Development using iOS 10.1 and quick 3.
source share