[英]Add Online Offline Status in Flutter App Like Whatsapp using Firebase but how i Handle without internet
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'.如果我关闭 wifi 然后关闭应用程序,didChangeAppLifecycleState() 将尝试在 Firestore 中将状态设置为“离线”,但是由于 wifi 已关闭, Firestore 无法将状态设置为离线......所以,其他用户应用程序将看到该用户“在线”。 How can I fix this?
我怎样才能解决这个问题?
Firestore has no built-in capability to write something in the database after the client has disconnected. Firestore 没有在客户端断开连接后在数据库中写入内容的内置功能。 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.一个例外是 Firebase 的另一个数据库:Realtime Database,它有所谓的
onDisconnect
处理程序,这些处理程序是您在连接时延迟写入数据库的指令,一旦数据库检测到连接消失,它就会执行。
You can combine the Realtime Database with Firestore as shown in the links below.您可以将实时数据库与 Firestore 结合使用,如下面的链接所示。
See:看:
onDisconnect
handlers .onDisconnect
处理程序的 FlutterFire 文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.