I created a new Xcode project, added the 'Firebase' pod to my pod file and installed it, and added the Google-services.plist file and the rest according to the Firebase documentation.
import Firebase works fine, but if I try
var ref:FIRDatabaseReference!
in the same ViewController, then it throws an error:
Use of undeclared type 'FIRDatabaseReference'
And this happens for any Firebase References. Any ideas on this? I am very new to Swift and the xCode IDE.
A Reference represents a specific location in your Database and can be used for reading or writing data to that Database location. You can reference the root or child location in your Database by calling firebase. database(). ref() or firebase.
Firebase orderByChild once child_added is only giving one child. 0. Returning a single child's value on Firebase query using orderByChild and equalTo. 3. unspecified index when searching data with firebase cloud function on nested object running nested Query.
A DataSnapshot instance contains data from a Firebase Database location. Any time you read Database data, you receive the data as a DataSnapshot.
addValueEventListener() keep listening to query or database reference it is attached to. But addListenerForSingleValueEvent() executes onDataChange method immediately and after executing that method once, it stops listening to the reference location it is attached to. Follow this answer to receive notifications.
As in swift4 the FIRDatabaseReference
has been renamed to DatabaseReference
So, use:
var ref:DatabaseReference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With