I don't really have a full solution for you but maybe I can help you think through the problem. Since my strength is software development and not database architecture I always think about how I'm going to implement the code. (Translation: what makes my life easier programmer)
First let's define what the status' really mean *your definition may vary
pending - user has made client side request for their message to be sent
sent - server has received the message
delivered - recipient client has received the message
read - recipient user has opened the specific message on their device.
the server doesn't really need to know about pending, seems like that would just be the default status on client side until the client can confirm the server has received the message at which point we can update the client to show that the message is sent. Sent seems like it should be the default setting on the server side. By the nature of firebase data will be read as soon as it's changed through a callback.
For example on the webside when we read data like in the example:
"myFirebaseRef.child("location/city").on("value", function(snapshot) {
alert(snapshot.val()); // Alerts "San Francisco"
});
the value
event will fire once for the initial state of the data, and then again every time the value of that data changes. "
Value event listener on the android side.
It's essentially being delivered as soon as it's sent (assuming the client has network connection), so as soon as the callback or listener triggers put a call in your logic to update it to delivered. And finally, you'd need to decide which events the recipient can make that qualify as "Reading" (selecting message from conversation list, focusing on text entry box, (if mobile looking at the screen?)) And make the update here too.
So on the database side you can just have maybe a status variable that is initially "sent" and then update it as events are triggered by the recipient.
Seems like just another variable that you'll constantly update.
Good luck!