期间未收到在集合中添加文档的回调offline。它在在线模式下运行良好。
但是,文档正在被添加,并且侦听集合的侦听器正在被添加document快照。
let database = Firestore.firestore()
let data = prepareRawDataFromObject(model)
if let data = data {
printLog("???? Collection: \(collection)????")
printLog("???? Data Request: \(String(describing: data)) ????")
var documentRef: DocumentReference? = nil
documentRef = database.collection("collection").addDocument(data: data) { (error) in
if let error = error {
failure()
printLog("???? Adding Document \(collection): \(error.localizedDescription) ????")
} else {
printLog("✅ Document Added successfully...✅")
success(documentRef!.documentID)
}
}
}
既没有success
听众也不是failure
如果您的设备将调用侦听器cannot到达 Firestore 后端。仅当数据提交到 Firebase 服务器或被 Firebase 服务器拒绝后,才会调用成功/失败侦听器。这就是您的设备在离线时无法获得任何信息而在设备在线时却能正常工作的原因。
因此,如果在写入操作完成时侦听器仍然存在,换句话说,当设备重新联机时,那么它将被调用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)