I am using the library FirebaseDatabase.net to use RealTime Firebase in Xamarin and it works very well when the device is online. Now I would like to save local data when cellphone is offline and when it turn back online the data should be synchronize automatically.
How could I to do this ?
So far I am trying this. It just working online
public class FirebaseService {
FirebaseClient firebase = new FirebaseClient("https://xxxxxxx-xxxx-xxxx.firebaseio.com/");
public async Task AddContato(int id, string nome, string email){
await firebase
.Child("Contatos")
.PostAsync(new Contato() { Id = id, Nome = nome, Email = email });
}
public async Task<List<Contato>> GetContatos(){
return (await firebase
.Child("Contatos")
.OnceAsync<Contato>()).Select(item => new Contato
{
Nome = item.Object.Nome,
Email = item.Object.Email,
Id = item.Object.Id
}).ToList();
}
}