Not getting the callback on adding document in the collection during offline. Its working good in online mode.
However, the document is getting added, and the listeners listening to the collection is getting the added document snapshot.
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)
}
}
}
Neither the success listener nor the failure listener will be called if your device cannot reach Firestore backend. The success/failure listeners will only be called once the data is committed to, or rejected by the Firebase servers. This is the reason you aren't getting anything while your device is offline and it is working properly when the device is online.
So if the listener will still exist when the write operation will complete, with other words when the device is back online, then it will be invoked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With