This must be something easy to be done, and I'm doing something stupid, but for 4 hours I can't understand what I'm doing wrong. I have databse entity like this:
posts:
-KK-3ajDuSUglnMMdXgy
authorId: "DYI4TPbwQocFsVROStUqcGNFHhW2"
authorName: "john"
privacy: "PrivacyTypeWorld"
text: "some post text"
Post can have 3 levels of privacy: for all (PrivacyTypeWorld), only for author (PrivacyTypePrivate), and for friends (friendId, friendId, ...).
My security rules look like this:
{
"rules": {
"posts": {
".read": "auth != null && (data.child('privacy').val() === 'PrivacyTypeWorld')",
".write": "auth != null"
}
}
}
But with this rules I see nothing. If I set ".read": "auth != null"
- all works fine.
What I'm doing wrong?
Edit:
To retrieve data I use:
_refHandle = [[_ref child:@"posts"] observeEventType:FIRDataEventTypeChildAdded
withBlock:^(FIRDataSnapshot *snapshot) {
[_arrPosts addObject:snapshot];
[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:_arrPosts.count-1 inSection:0]] withRowAnimation: UITableViewRowAnimationAutomatic];
}];