Loading data from firestore while offline works as expected but a call to save never returns and there seems to be no timeout either.
This is a example save that works online but not offline:
func save() {
guard let uid = user?.uid else {
return
}
let db = Firestore.firestore()
var ref: DocumentReference? = nil
ref = db.collection("users").document(uid).collection("properties").addDocument(data: ["name": "test"]) { err in
if let err = err {
print("Error adding document: \(err)")
} else {
print("Document added with ID: \(ref!.documentID)")
}
}
}
Is there any known workaround?
UPDATE: Firebase support have confirmed it's a bug and that it "is now being worked on by our engineers". They are unable to give a timescale for when it will be fixed.
This is the expected behaviour - you should assume that the write will happen when the device comes back online. In my use cases, I've just continued with the normal flow and used my local data as my source of truth.
It's mentioned here: https://youtu.be/XrltP8bOHT0?t=680
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