We have developed the chat application in flutter and the backend is Firestore, which has a one-to-one and group chat functionality and is working fine as expected, including the ability to track if the user is online or offline with last seen date/time.

When a user is online, we mark it as online along with updating the last seen date/time. If the user sends another message, we also update the last seen date/time again just to ensure the latest last seen date/time updated.

Also, We mark it as offline when the user closes or loses focus from application.

Problem Statement: We could not be able to update that information in the FireStore database when the user disconnects the phone from mobile data or WiFi connection.

Any suggestions would be greatly appreciated.

Regards,
Hi Ten