JamesG JamesG - 2 months ago 29
Swift Question

Read from firebase database with Swift

I'm struggling to get the value I need from Firebase

I have this setup

- version : 1.0

and I am trying to get it like so:

let refHandle = dbRootRef.observe(FIRDataEventType.value, with: { (snapshot) in
let postDict = snapshot.value as? [String : AnyObject] ?? [:]

Can someone help me get the 1.0 from the database?

p.s - no errors and nothing in the console

Jay Jay

try this

let ref = "path to your Firebase/version" //point directly to the version node

ref.observe(FIRDataEventType.value, with: { (snapshot) in
        print(snapshot?.value) //prints 1

Testing rules: set to

  "rules": {
    ".read": true,
    ".write": true