Q:

Print All Children Columns from Firebase - iOS Swift 4

I have 2 records in my users table 

This code below
let fcmTokenRef = Database.database().reference().root.child("users").child(id!).child("fcmToken")
fcmTokenRef.observe(DataEventType.value, with: { (snapshot) in
    print(">>",snapshot)
})

will print out the token of a child

How do I adjust my code to print all the tokens for all my children? 

A:

You can try
let fcmTokenRef = Database.database().reference().root.child("users").observe(DataEventType.value, with: { (snapshot) in 
      print(">>",snapshot)

      let dic = snapshot.value as! [String:[String:Any]]
      Array(dic.values).forEach { 
        let str = $0["fcmToken"] as! String
        print(str)
     }
})

