So i'm a bit new to firebase and i'm developing an android app. What I would like to do is this: I want to create a service that runs in the background that can listen to a whole collection in firestore (For example "messages"), and once a document is added to the collection I would like to check if the document contains a certain value, and if it does push a notification. An outline of the pseudocode:
messages.attachlistener(onNewDocument(doc) -> {
if(doc.getString(username) == my_username)
{
send_notification(doc.getString(message));
cache_message_for_later();
delete_doc_from_table();
}
};
My question is this: Is attaching a listener to a collection possible? I only found document listeners in the docs. If it is possible, would such a listener even be viable performance wise? (My thinking: this service would be running in the background at all times, but documents would get deleted after being cached so the table size wouldn't be too large and it might balance out?)