Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving to Cloud Firestore on iOS hangs when offline

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.

like image 416
Keith Coughtrey Avatar asked Nov 19 '22 03:11

Keith Coughtrey


1 Answers

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

like image 75
d3raymon Avatar answered Dec 04 '22 12:12

d3raymon