Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase offline capabilities in ionic / cordova

Has anybody implemented a native app with Firebase with full offline capabilities in Android/iOS?

Could this be done in Cordova/Ionic with a plugin that uses the native Firebase SDKs?

We are building an app that has connection at download and first start but then we have to assume there is no more internet connection for a while and all content from the database has to be available offline. Is Firebase suitable for this requirement or do we have to use CouchDB/PouchDB or any other alternative?

EDIT:

This question referred to the firebase realtime database. I believe that with the new firebase Cloud Firestore offline capabilities for ionic are supported out of the box:

https://firebase.google.com/docs/database/rtdb-vs-firestore

Realtime Database: Offline support for mobile clients on iOS and Android only.

Cloud Firestore: Offline support for iOS, Android, and web clients.

like image 1000
chris08002 Avatar asked Nov 06 '16 10:11

chris08002


People also ask

Is it possible to use Firebase offline?

By enabling persistence, any data that the Firebase Realtime Database client would sync while online persists to disk and is available offline, even when the user or operating system restarts the app. This means your app works as it would online by using the local data stored in the cache.

Can Firebase be used with ionic?

Ionic developers can use Firebase to build rich features into their mobile apps and to monitor and improve app quality over time.

How does firestore work offline?

With offline persistence enabled, the Cloud Firestore client library automatically manages online and offline data access and synchronizes local data when the device is back online. For Android and iOS, offline persistence is enabled by default. To disable persistence, set the PersistenceEnabled option to false .

How does ionic Firebase store data?

Setting up the Firebase Storage ionic App Next we need to load the plugins and also connect our app to Firebase. Here we need the configuration you copied earlier, so replace the values with yours in the code below. Also, add all the needed AngularFire modules to your imports so we can use them later.


1 Answers

There is no real "offline" support for firebase in their JS SDK. The offline solution they have right now means you will have offline support if you lose internet connection and if the connection goes "online" data will sync back. BUT if you close the app before going online again your "offline" data is lost.

The is a Cordova firebase plugin https://www.npmjs.com/package/cordova-plugin-firebase but it does not support the realtime database yet. you can try and extend this if you want.

if you must have an offline support i suggest you either use SQLite or CouchDB/PouchDB that you mentioned.

like image 52
Danny Ogen Avatar answered Sep 20 '22 22:09

Danny Ogen