We are working with Google Firebase 3.x, and we have a strange problem with Firebase. We use Swift 3.0 and to obtain information about the user, we use the following code fragment:
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) }) }
This code is never called in a real device, and we do not get any error logs, but the same code works in the simulator. This is a strange problem, and yes, I already checked a similar question: Firebase did not work on real devices (iOS)
I also tried disabling BitCode, but that didn't work.
We are using an iOS 9 device with Xcode 8. Any help is appreciated.
source share