My firebase database has a child which is name is Messages and it has children user_id and also it has children which are title and timestamp such as:
my firebase database
- Messages
- user_uid_1
- Title
- timestamp
- user_uid_2
- user_uid_3
- ...
- user_uid_1
- Messages
I want to add a addChildEventListener for Messages to determine if there are any change in Messages. this is very easy with this code:
myRef.child("Messages").addChildEventListener(new ChildEventListener()...
how about firebase rules. if I made it public it works. but if I do like that child listener NOT working what should I add to my rules
{
"rules": {
"Messages":{
"$uid":{
".read": "data.child('timestamp').val() > (now - 18000000)",
".write": "auth != null"
}
},
"$other":{
".read": true,
".write": "auth != null"
}
}
}
I want to read only messages from the last 30 minutes can be read so that I've added ".read": "data.child('timestamp').val() > (now - 18000000)",.
I think I should add something between "Messages" and "$uid" to addchild listener correctly. thnks!