We are working with Google Firebase 3.x version and we faced strange issue from Firebase. We are using Swift 3.0 and for getting user details, we are using the following code snippet:
func getUserDetails(uid text:String!, userBlock:@escaping (_ details:AnyObject) -> Void) {
//check DB Reference is nil or not.
if self.rootDBRef == nil {
self.rootDBRef = FIRDatabase.database().reference()
}
//check input text must not be empty
if text.trim().characters.count == 0 {
userBlock("" as AnyObject)
return
}
let query = self.rootDBRef.child("users").queryOrdered(byChild: "uid").queryEqual(toValue: text)
query.observeSingleEvent(of: .value, with: { (dbSnapshot) in
guard let snap: FIRDataSnapshot? = dbSnapshot else {
print("No Result Found")
return
}
if snap?.value is NSNull {
//block(found: false)
userBlock("" as AnyObject)
return
}
let dict = snap?.value as! [String : AnyObject]
userBlock(dict as AnyObject)
})
}
That code never gets called in a real device and we're not getting any error logs, but that same code works in a simulator. Its a strange issue and yes, I have already checked a similar question: Firebase not worked on real devices (iOS)
I've also tried to disable BitCode as well, but that didn't work at all.
We are using iOS 9 device with Xcode 8. Any help is appreciated.