Firebase 3x does not work on a real device, but works on a Swift 3.0 simulator

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.

+5
source share
2 answers

I think the problem is authentication . You must have Enable authentication on Firebase , but not Authenticate the user . Therefore, you are not allowed to access the database on Firebase strong>.

+1
source

You need to enable anonymous login in FireBase

Anonymous login

And according to the FireBase documentation

Do you need to add FIRAuth.auth()?.signInAnonymously() to didFinishLaunchingWithOptions in AppDelegate to enable anonymous login

0
source

All Articles