I want to notify users that are in the same "room" for changes. The scenario: I have anonymously devices with an id saved with an name. I have rooms with an unique id and name. And I have the link between them based on the device id and room id.
It looks like this:
Every device in the devices rooms "table" linked under the same key should be notified. When data changes under that key. But now the part what I don't get.
I want to get the device name of each device under the devices rooms key. And yes I want to get an update as well when the name changes. How can I do this with the authorization etc?
I have this basic code right now to write all this data to the database:
var ref: DatabaseReference! = Database.database().reference()
ref.child("devices").child(user!.uid).child("device_name").setValue("iPhone test")
let newRef = ref.child("rooms").childByAutoId()
newRef.child("name").setValue("Room test")
ref.child("devicesrooms").child(newRef.key).child(user!.uid).setValue(true)
let ev = ref.child("devicesrooms").child(newRef.key)
ev.observeSingleEvent(of: .childAdded, with: { (DataSnapshot) in
print("changed")
})
