gpt4 book ai didi

ios - Firebase 快速返回 incored 快照

转载 作者:行者123 更新时间:2023-11-28 13:46:00 25 4
gpt4 key购买 nike

我有一个 firebase 聊天应用程序,我正在尝试获取用户凭据,但我在控制台中从 firebase 获取了错误的值

enter image description here

这就是我的引用和快照,当我决定在控制台中打印它时,我得到了它

CREDENTiL data ref Optional({
"cc71128f-99a7-4435-879b-b1d0c7ce9c37" = {
location = "-Lav1QzhaoRMGAJHy8nQ";
};
})
CREDENTiL data ref Optional({
email = "adie.olalekan@max.ng";
name = "Olalekan Adie";
profilePicLink = "http://www.freeiconspng.com/uploads/profile-icon-9.png";
})

这是我的代码

self.allUserRef?.observe(.childAdded, with: { (snapshot) in
let id = snapshot.key
print("CREDENTiL data ref \(snapshot.value)")

if let data = snapshot.value as? [String: AnyObject] {
if snapshot.hasChild("credentials") {
print("CREDENTiL data \(data)")
if let credentials = data["credentials"]! as? [String: AnyObject] {
print("CREDENTiL \(credentials)")
if id != exceptID {
let userInfo = ChatUser(dictionary: data as NSDictionary)
}
}
}
}
})

任何帮助将不胜感激

最佳答案

let refer = Database.database().reference()

refer.child("chatUsers").child("your uid").observe(.childAdded, with: { (snapshot) in
let id = snapshot.value//your snapshot
if((((snapshot.value as! NSDictionary).allKeys) as! NSArray).contains("credentials"))
{
print("credentials",snapshot.value)
}
})

请尝试上面的代码以获取您的凭据作为快照。

关于ios - Firebase 快速返回 incored 快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55373414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com