iOS应用程序中的Firebase在线状态系统 [英] Firebase presence system in iOS application
本文介绍了iOS应用程序中的Firebase在线状态系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将Firebase集成到我的iOS应用程序中,我想集成用户状态系统,是否有任何Firebase API可以跟踪哪个用户在线&离线?
I have integrated Firebase into my iOS apps I want to integrate user presence system, is there any Firebase API that tracks which user is online & offline?
推荐答案
是的,有办法
您可以使用firebase的 .info/connected
You may use firebase's .info/connected
每次Firebase的实时数据库"客户端连接状态更改时,此更新.
This is updated every time Firebase's Realtime Database client connection state changes.
let connectedRef = Database.database().reference(withPath: ".info/connected")
connectedRef.observe(.value, with: { snapshot in
if snapshot.value as? Bool ?? false {
print("Connected")
} else {
print("Not connected")
}
})
这篇关于iOS应用程序中的Firebase在线状态系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文