I am developing a chat application like Facebook. In home page I am listing all the chats, When opening a chat I am calling a REST API for getting new messages. Only after opening a chat I am calling the rest API for listing new messages. From the home page, there is no way to get new message details.
Also, I implemented the push notification in my app using FCM. The push notification will receive when a new message comes.
Form this implementation how can I show the number of unread messages in a chat? Please suggest a suitable solution to show the unread message count?
Is this feature possible to implement using push notification? But push notification's OnMessageReceived()
is executed only when the app is in a foreground state. When the app is in the background or killed state OnMessageReceived()
will not execute. Also notifications are not received when the app is in log out state.