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.
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)
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