Tony Ong Tony Ong - 5 months ago 98
iOS Question

Unable to read data from firebase

Recently i am trying working on an IOS app and had just started using the newly revamp firebase for all the backend stuff. I was following the default IOS tutorial below

https://codelabs.developers.google.com/codelabs/firebase-ios-objc/index.html?index=..%2F..%2Findex#0

for firebase and trying to integrate a portion of the code in the tutorial into my IOS app project.

Basically, I am trying to read data from firebase and display it on my IOS app, however, i am unable to get it to work and I can't figure out why.

With the help of the tutorial, I had completed the below needed steps
1) Added GoogleService-Info.plist file
2) Input the correct bundle ID
3) Installed all the Firebase related pods
4) Added the rules to "read" and "write" the data

Below is an image of my firebase database:

enter image description here

Below is an image of my function to read data from firebase:

enter image description here

I do not encounter any major error when running the app. I can compile the code smoothly. However, I just can't get the code to print out the data in the Xcode console using NSLog.

Any kind advise?

Answer

You are not getting data because you are querying for a key hotel_bookings while on the firebase side you have key hotel bookings,

You can do either one thing , convert your key to hotel_bookings in your FireBase Database and its a good thing not have spaces in your keys.

See if this helps..

Comments