if I turn off wifi and then close the app, didChangeAppLifecycleState() will try to set the status to 'offline' in Firestore, but as wifi is off Firestore can't set the status to offline... So, other users of the app will see that user 'online'. How can I fix this?


Solution 1: Frank van Puffelen

Firestore has no built-in capability to write something in the database after the client has disconnected. In fact, most databases don't have such a capability.

One exception is Firebase's other database: the Realtime Database, which has so-called onDisconnect handlers, which are delayed write instructions that you to the database when you are connection, and which the database then executes once it detects that the connection is gone.

You can combine the Realtime Database with Firestore as shown in the links below.

See: