Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firestore callback for offline save in android

I have recently enabled offline data for my android app which is using Firestore. The problem I have while saving the data is that i am not getting callback after data is saved (when client is offline i understand it will be stored offline).

Sample Code

    batch.set(mFirestore.document("documentPath"), documentMap); 
    batch.set(mFirestore.collection("history").document(), historyMap);

    batch.commit().addOnSuccessListener(new OnSuccessListener<Void>() {
        @Override
        public void onSuccess(Void aVoid) {
            view.onSuccess();
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            view.onFailed(e.getMessage());
        }
    });

In the above code neither SucessListener nor FailureListner is called, however data is getting saved offline. Please help.

like image 795
Prashant t Avatar asked Feb 18 '18 09:02

Prashant t


1 Answers

Currently, there's no callback for local writes after adding data to your database. The addOnSuccessListener() method only triggers when the write has been committed to the database. This is feature request for future .. answer received from firestore support (20 Feb 18)

like image 99
Prashant t Avatar answered Sep 28 '22 02:09

Prashant t