I have a Firebase Realtime Database and want to get the name of a child in the last part of a branch.
The database structure looks like this:
How do I get the "FD4936E20732A42E" and possible other child names of "friends"?
"FD4936E20732A42E" and other possible childs of "friends" are not string values I know before runtime.
I know how I would for example access the value for a specific part of the database. But in this case using snapshot.value and snapshot.key did not work.
I really appreciate any kind of help. I am really desperate.
Update - I tried this but the output is a FIRDataSnapshot and I need a String. A downcast is not working:
let ref = Database.database().reference().child("visitors").child("107C081B-4117-4E2F-8E39-BF896D366B30")
ref.child("friends").observeSingleEvent(of: .value) { snapshot in
for child in snapshot.children {
print(child)
}
}
The output I get:
Snap (FD4936E20732A42E) 1