rlamasb / Firebase.Xamarin

Light weight wrapper for Firebase Realtime Database REST API.
MIT License
149 stars 39 forks source link

How to enable Offline database? #17

Open jcampana opened 7 years ago

jcampana commented 7 years ago

I tried to enable Offline database for get data when network connection is not available. Is it possible with this framework? Not? Any solution for this?

Thanks

se1exin commented 7 years ago

@jcampana I've tried this on a project and ended up using CouchDB instead, as Firebase.Xamarin doesn't support Offline Database

talihomz commented 7 years ago

@jcampana I managed to make it work offline. Firebase Xamarin is a rewrite of Firebase Database, so I'm using the original implementation of Offline database as my Offline Database Factory.

My constructor now looks like this: `var _instance = new FirebaseClient(

, (t, s) => new OfflineDatabase(t, s) );` The offline database uses [Lex.Db](https://github.com/demigor/lex.db) which you will need to install from nuget to make it all work.
pallavbohara commented 7 years ago

@talihomz Can you share sample app? which uses var _instance = new FirebaseClient( <My Firebase Url>, (t, s) => new OfflineDatabase(t, s) ); Because when i use it, it gives this error-- Object reference not set to an instance of an object. at Lex.Db.DbInstance.Initialize ()

felipeoliveirar commented 7 years ago

That means I have to include a new offline database? like this Lex.DB? and it will work correctly? the framework check if the internet returns and load the offlineDatabase that was include in your example?

v-sharaev commented 6 years ago

@pallavbohara I have some problem. How you fix it?

zanesc commented 6 years ago

@talihomz The original implementation of Offline database that you linked to no longer exists.

For anyone looking to implement this: 1) Save the OfflineDatabase.cs class found here to your project: https://github.com/step-up-labs/firebase-database-dotnet/blob/021d00a08373f535af93d66944404719be86ee58/src/Firebase/Offline/OfflineDatabase.cs 2) Install LiteDB from nuget 3) Use var firebase = new FirebaseClient(, (t, s) => new OfflineDatabase(t, s));

zanesc commented 6 years ago

I am not sure when but at some point the offline database stopped working. It seems that there is a HttpRequestException thrown when trying to make a call to the database if not online. For some reason it is not attempting to use the offline database instance when it fails to connect to the server.

masodev commented 6 years ago

Hey there @zanesc any updates on this issue?