Use Firebase without Internet

0

Good, I ask you another question, because I know I can count on your help.

I have been starting to use Firebase, which is why I have some doubts. If Firebase is made to be used without internet, then how do I confirm if an "action" is executed, for example:

ref.child(user.getUid()).child("Animales").child(child.child("id").getValue(String.class)).removeValue();

It is a reference to a node that I want to delete, but I need to make another "action" when it is confirmed. If I use:

ref.child(user.getUid()).child("Animales").child(child.child("id").getValue(String.class)).removeValue().addOnCompleteListener()...

or

ref.child(user.getUid()).child("Animales").child(child.child("id").getValue(String.class)).removeValue().addOnSuccessListener()..

They serve me perfectly, but only if I have an internet connection. By the way, my disk persistence is working fine.

    
asked by Wayner 23.02.2017 в 04:17
source

1 answer

0

To be able to enable this option you should wait for the event onDisconnect() :

var connectedRef = firebase.database().ref(".info/connected");
connectedRef.on("value", function(snap) {
  if (snap.val() === true) {
    alert("connected");
  } else {
    alert("not connected");
  }
});

You can get more accurate information in this link in the documentation of Firebase.

    
answered by 01.03.2017 в 17:51