firebase Firebase Offline Capabilities Keeping data fresh (Android/iOs Only)


Example

Firebase synchronizes and stores a local copy of the data for active listeners when used on mobile devices. In addition, you can keep specific locations in sync.

Android :

DatabaseReference workoutsRef = FirebaseDatabase.getInstance().getReference("workouts");
scoresRef.keepSynced(true);

iOs:

//Objetive-c
FIRDatabaseReference *scoresRef = [[FIRDatabase database] referenceWithPath:@"scores"];
[scoresRef keepSynced:YES];
//Swift
let scoresRef = Database.database().reference(withPath: "scores")
scoresRef.keepSynced(true)

Firebase client automatically downloads the data at these locations and keeps it updated even if the reference has no active listeners. You disable synchronization with the following line of code.

Android :

scoresRef.keepSynced(false);

iOS:

[scoresRef keepSynced:NO]; //Objetive-C
scoresRef.keepSynced(false) //Swift