5

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.

Community
  • 1
  • 1
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • 1: Is there any other console output from the Firebase SDKs 2: Are there any rules on your database? – Ian Barber Sep 26 '16 at 19:33
  • hi @lan no there is no any console output and nothing we get from firebase thats the main things thats why we can not idenfity whats the issue – Nitin Gohel Sep 27 '16 at 06:11
  • @frank van can you please help – Nitin Gohel Sep 27 '16 at 06:11
  • Are there any rules set up on the database (note: there are rules by default)? The issue could well be connected to auth. – Ian Barber Sep 27 '16 at 16:15
  • @nitin ghoul hi, was you able to find the fix to this problem? The same thing has been happening to me all day. I can send/retrieve data through my app with the simulator but on a real device it won't let me do anything. – Lance Samaria Oct 21 '17 at 01:15
  • there are 2 way to fix it. One is to access direct user's database of firebase you need to change in rules or you must be authenticate before access anything. – Nitin Gohel Oct 23 '17 at 06:50

1 Answers1

0

I think the problem is on Authentication. You must have Enable Authentication on Firebase but has not Authenticate user.So you are not allowed to access the database on Firebase.

saroj raut
  • 834
  • 8
  • 16
  • No, it's not the reason. I`ve successfully sign-in with the same account on both simulator and iphone, but on real device DB is not accessible. – Jurasic Mar 24 '17 at 12:32