addOnCompleteListener not called offline with cloud firestore

I have been writing an app using the new cloud firestore database. It works great except the fact that many things are not working smoothly when offline although the offline persistence is enabled. For instance I do the following:

ref.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    //Do something
                } else {
                    //Do another thing
                }

            }
        });

However the onComplete method is never called when offline. I want to close the activity and show some Snachbar once this happens. But as it never does, the activity remains open. I am using android studio emulator.

Thanks


Solution 1:

Operations that write to the database are defined to signal completion once they've actually committed to the backend. As a result this is working as intended: while offline they won't signal completion.

Note that the Firestore clients internally guarantee that you can read your own writes even if you don't wait for completion of the task from delete.

For the most part this means that you shouldn't need to wait for this task to complete. Is there any particular reason you're interested in doing so?