8

I install Firebase in my iOS app. Everything works fine on simulator but on real device it doesn't execute / return a query to my database.

I try to clean the project but it doesn't change anything.

Have you a solution ?

EDIT : Update with code

override func viewDidLoad() {
    super.viewDidLoad()

    // Setup Firebase
    self.ref = FIRDatabase.database().reference()



    self.ref.child("Database").observeEventType(.Value, withBlock: { (snapshot) in


        if snapshot.exists() {
            for rest in snapshot.children.allObjects as! [FIRDataSnapshot] {
                print(rest.value)


            }
        } else {


        }

    }) { (error) in
        print(error.localizedDescription)
    }
}
Jojo
  • 449
  • 1
  • 7
  • 16

3 Answers3

3

There is no fault in your code, I had the same problem. Here is what I did:

  1. Simply go to Your Project in the navigation pane on the left.

  2. Go to Build Settings and scroll down to Build Options.

  3. Change the value of Enable Bitcode to No.

Hope it works out for you too!

Josh
  • 529
  • 6
  • 21
  • 1
    @user1585646 none of these answers helped me. But i'm explicitly logged out from real device and then sign in again, and DB immediately start responding. I think Firebase cached key and didn't renew it properly. – Jurasic Mar 24 '17 at 13:58
2

I found that if you logged in, and delete the application, then after you install the application again, you will still be logged in. I do not know exactly, but I assumed that Firebase somehow binds the account cache to the Bundle Identifier, not in the local storage.

So the solution is simple and it worked for me:

  1. Remove the your APP from real device.
  2. Go to your project in Navigation Panel.
  3. In General tab change your Bundle identifier, for example: "myApp.com" to "myApplication.com" or whatever you want.
  4. Build and run
  5. Bingo! Now your app should interact well with Firebase again.

Update: Firebase remembers your login in the keychain

Update: Firebase remembers your data in keychain using your Bundle identifier as key

codethemall
  • 144
  • 1
  • 5
0

I had the same problem and it was due to Authentication. Authentication was Enable on Firebase but I have not Authenticate User. So I was not able to read the Node from Firebase Database.

saroj raut
  • 834
  • 8
  • 16