Offline issue with Firestore vs Firebase

前端 未结 4 1595
梦谈多话
梦谈多话 2020-12-31 09:44

I converted one of my apps to the new Firestore. I am doing things like saving a document on a button click, and then in the onSuccess listener, going to a diff

4条回答
  •  Happy的楠姐
    2020-12-31 10:16

    For offline support you need to set Source.CACHE

    docRef.get(Source.CACHE).addOnCompleteListener(new OnCompleteListener() {
        @Override
        public void onComplete(@NonNull Task task) {
            if (task.isSuccessful()) {
                // Document found in the offline cache
                DocumentSnapshot document = task.getResult();
    
            } else {
                //error
            }
        }
    });
    

提交回复
热议问题