问题
I just want to make a query and search if an email exists, but my query never gets called. This is my code:
func emailAvailable(email: String, completion: (result: String)-> Void){
let ref = self.dbRef.child("usuarios")
ref.queryOrderedByChild("emailUsuario").queryEqualToValue(email).observeSingleEventOfType(.Value, withBlock: { snapshot in
//NEVER ENTER HERE
if snapshot.exists(){
completion(result: "N")
}else{
completion(result: "Y")
}
})
}
For test I only have this in my realtime Database:
usuarios{
daniel{
emailUsuario: "daniel@test.com"
},
omar{
emailUsuario: "omar@test.com"
}
}
This problem wasn't happening before I upgrade to the new Firebase. I even test with no data at all, and the snapshot was Nil.
I have configured Firebase in AppDelegate like the documentation and the values in my GoogleService-Info.plist is ok. Thanks in advance for your help
来源:https://stackoverflow.com/questions/37958065/ios-swift-firebase-query-never-gets-called