Reputation: 150
I'm getting an error while offline.
I already set the Persistence to True
and getting some cached data while offline, but there is one function that gives me this offline error. The logcat point me on task.getResult().exists()
.
I don't know what to do, can anyone help me?
ERROR: com.google.android.gms.tasks.RuntimeExecutionException: com.google.firebase.firestore.FirebaseFirestoreException: Failed to get document because the client is offline.
firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").document(currentUserId).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if(!task.getResult().exists()){ //I GET ERROR HERE
Map<String, Object> likesMap = new HashMap<>();
likesMap.put("timestamp", FieldValue.serverTimestamp());
firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").document(currentUserId).set(likesMap);
} else {
firebaseFirestore.collection("Posts/" + blogPostId + "/Likes").document(currentUserId).delete();
}
}
});
Upvotes: 1
Views: 4664
Reputation: 82
for me in flutter android app development process
note: I know only for android.
Upvotes: 1