1

我有一种情况,我的 Firebase 引用没有调用 observeSingleEvent 的回调。

 let uid = FIRAuth.auth()?.currentUser?.uid

 FIRDatabase.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: { (snapShot) in                    
           //code here not called
        }) { (error) in
           //code here not called either
        }

FIRAuth.auth()?.currentUser?.uid在我的情况下,当我在 Firebase 环境之间切换(使用不同的开发和暂存 .plist 文件构建)时,似乎来自以前的应用程序安装的 uid 属性以某种方式被缓存。

但是,如果我只是添加一个随机不存在的字符串来代替 uid,则回调会按预期发生,并且缺少参考节点的空快照。

我相信有必要提到我正在使用带有 persistenceEnabled = true 的同步 Firebase 引用。

我处于在环境之间切换并且我的应用程序挂起的情况,因为承诺没有被履行或拒绝,因为observeSingleEvent方法调用的结果永远不会完成。

4

0 回答 0