I have built an application with Firebase and I've also made a desktop version available with nw.js. The point of this being to allow for better offline usage in areas with bad or no internet (and it will sync when the user gets internet again). Now, I can disconnect just fine and reconnect while the app is running, but I want to be able to fully close and reload the application. I've seen this blog post from firebase, but it appears this only works for mobile platforms.
Is this currently possible on the web platform, too?
All Firebase SDKs will handle intermittent loss of connectivity (driving through a tunnel). But disk based persistence, which allows the data to survive an app restart, is currently only available in Firebase's iOS and Android SDKs.
Related
To use a firestore bundle, does the client need to have persistence enabled for the offline cache. If persistence is enabled, does it mean that the offline cache and the bundle are retained when the app or browser is closed and don't have to be re-downloaded when the app or browser window starts up again.
According to the firebase website, for the web, offline persistence is supported only by chrome, safari and firefox. Is this information up to date - is it possible that Edge, Opera and Brave browsers support persistent cache.
For the web, if cache persistence isn't available, is it possible to cache the firestore bundle locally some other way?
If the app requests to ead a document from the local cache and it's not there, will the document be read from the cloud if the device is online?
When you enable disk persistence, your app writes the data locally to the device so your app can maintain state while offline, even if the user or operating system restarts the app.
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. Listener callbacks will continue to fire for local updates.
Check the section here for more information on Handling Transactions Offline
Even with persistence enabled, transactions are not persisted across app restarts. So you cannot rely on transactions done offline being committed to your Firebase Realtime Database. To provide the best user experience, your app should show that a transaction has not been saved into your Firebase Realtime Database yet, or make sure your app remembers them manually and executes them again after an app restart.
As per the official documentation ,Offline persistence is supported only in Android, Apple, and web apps.For the web version, offline persistence is supported only by the Chrome, Safari, and Firefox web browsers
For the web, offline persistence is disabled by default. To enable persistence, call the enablePersistence method.
While network access is disabled, all snapshot listeners and document requests retrieve results from the cache. Write operations are queued until network access is re-enabled.
Also , check the following for similar implementations examples:
Firebase Offline persistence Upfront Caching
Firebase Offline possibilities
What happens when an offline device goes online
I am a newbie to mobile development and I am building a mobile game in react native for android devices where I want to store user centric information such as score for different levels in realtime database in firebase. My users would be in playing game in restricted internet connectivity(where user connects to internet once in few days) and I want a mechanism such that app should store data locally even when the application "RESTARTS" or the app is killed by user and when internet connectivity comes, should be able to push all data on server.
I have two questions:
Can I some how automatically send data to server without user opening the app when the internet connectivity is established?
I found support for enabling offline data persistence in case of application or operating system restart for android in Java and kotlin
(https://firebase.google.com/docs/database/android/offline-capabilities), but did not find support for react native. I have gone through documentation of React Native Firebase library (https://rnfirebase.io/docs/v5.x.x/database/reference/database), but did find option to enable data persistence option for case when application/os restarts. Is there any workaround for this?
What you are looking for is Cloud Firestore, it has data persistence built-in so you won't have to worry. Use react-native-firebase for that, it has an absolutely beautiful documentation and guides and the community is very helpful too.
To sync your local data with the server without user opening app, you'll need to delve into the native side and make an Android Service that runs in the background and checks for internet connectivity regularly. As soon as the internet is connected, it can start the Cloud Firestore sync.
Do not use Realtime Database for this. Use Cloud Firestore which is way better.
I'm developing a Firebase based application using Ionic2 and Angularfire2. Does anybody know if its possible to setPersistenceEnabled(true) to allow for offline application use?
All Firebase SDKs handle intermittent connectivity loss, by keeping a cache of active data in memory and keeping a queue of pending writes.
Native mobile SDKs (for iOS and Android) have the ability to persist the cache and queue to disk, so that it survives app restarts. The web SDK does not have this ability.
I have built an application with Firebase and I've also made a desktop version available with nw.js. The point of this being to allow for better offline usage in areas with bad or no internet (and it will sync when the user gets internet again). Now, I can disconnect just fine and reconnect while the app is running, but I want to be able to fully close and reload the application. I've seen this blog post from firebase, but it appears this only works for mobile platforms.
Is this currently possible on the web platform, too?
All Firebase SDKs will handle intermittent loss of connectivity (driving through a tunnel). But disk based persistence, which allows the data to survive an app restart, is currently only available in Firebase's iOS and Android SDKs.
I have built an application with Firebase and I've also made a desktop version available with nw.js. The point of this being to allow for better offline usage in areas with bad or no internet (and it will sync when the user gets internet again). Now, I can disconnect just fine and reconnect while the app is running, but I want to be able to fully close and reload the application. I've seen this blog post from firebase, but it appears this only works for mobile platforms.
Is this currently possible on the web platform, too?
All Firebase SDKs will handle intermittent loss of connectivity (driving through a tunnel). But disk based persistence, which allows the data to survive an app restart, is currently only available in Firebase's iOS and Android SDKs.