I am writing a chat application and attempting to implement readReceipts. I have the following Firebase database structure, and when a message is opened, I will do a updateChildValue. This will update the Bool to true, like so:
Snap (messages) {
"-L7E-3km6bvx3WWFHeuj" = 1;
"-L7E-MXzwmZ9iv6Bj0oM" = 1;
"-L7E-N5pm-FGtb3m3AOr" = 1;
"-L7E-Q2cRJz9DDFgRWL_" = 1;
"-L7E-U4r1vd94i-xbNTh" = 1;
"-L7E1LdrJaqZDjIkWd7X" = 1;
"-L7EBz3hxfJ-E3f7joJ6" = 1;
"-L7EE8A5eZNyey12GcHB" = 1;
"-L7EEwX2m-rrPYFgDoA8" = 0;
"-L7EFA7CHfyRoECUkeLm" = 0;
"-L7EFPICxdWQcrLOEUkM" = 0; //Updating this will change Bool to 1
"-L7EJ1byG2KLKZf_Cspv" = 0;
"-L7EKRmXYz_94UrIPGhS" = 0;
}
I listen for childChanged on my messages node, and when the update changes to true, I will update the views of the collectionViewCells. However, implementing childChanged will always extract the whole messages node.
Is there a way to identify the exactly which id gets the update and hence obtain the indexPath to update the collectionViewCells? Alternatively, is there a better way to implement readReceipts?
childChangedevent fires on the child node that changed under the location where you listen. If that doesn't seem to work for you, post the minimal, standalone code that reproduces the problem. - Frank van Puffelen