简体   繁体   English

使用 Firebase 在 Flutter App Like Whatsapp 中添加在线离线状态,但我如何在没有 inte.net 的情况下处理

[英]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:看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Whatsapp 喜欢在线/离线状态与 firebase 反应本机 - Whatsapp like online/offline status in react native with firebase 如何在没有内容提供程序的情况下将自定义 WhatsApp 贴纸从 firebase 添加到 WhatsApp? - How to add a Customized WhatsApp Sticker from firebase into WhatsApp without Content Provider? 如何在 Flutter 应用程序中以离线模式使用 firebase 实时数据库? - How to use firebase realtime-database in offline mode in Flutter app? 如何在不强制用户注册的情况下保护 Flutter + Firebase 应用程序? - How to secure Flutter + Firebase app without forcing users to register? 发送whatsapp消息时如何处理twilio错误状态 - how to handle twilio error status when sending whatsapp message Firebase:如何在应用检查中注册我的 Flutter 应用? - Firebase: How do I register my Flutter app in app check? Firebase Crashlytics for Android app without inte.net connection - Firebase Crashlytics for Android app without internet connection 如何在不使用 Firebase 控制台的情况下使用 FCM 在 Flutter 应用程序中触发推送通知? - How to trigger push notifications in Flutter app using FCM without using the Firebase Console? Firebase V9在线状态 - Firebase V9 Online Status 如何在 flutter 不刷新的情况下从 firebase 检索数据 - How can I retrieve data from firebase without refresh in flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM