Persist data with firebase web - firebase

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

Does the firestore bundle facility require persistent offline cache in the client to be enabled

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

How to persist data locally with firebase realtime database in react native?

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.

Persisting state of Firebase data [duplicate]

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.

Ionic/Firebase store data local and sync [duplicate]

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.

Push Notifications - when the "push server" is personal for each app user (APNS is the issue here)

I have developed an app for an open source home security solution (ZoneMinder). The app I developed is called zmNinja (open source again) - and it works rather well. I am now implementing a mechanism to push notifications (motion detection alarms) to people who will use the app.
After going through the APNS and GCM documents, it looks like the "server" which sends the push to devices must integrate with SSL certificates and API keys generated from Apple and/or iOS. And this, specifically for apple requires a developer account.
Therein lies the predicament. Users of 'zoneminder' install their own servers. There is no central server. I've developed a event server that works with 'zoneminder' on web sockets that can be installed along with zoneminder and it sends notification when there are new alarms. This works very well on Android because Android allows the web socket to be open in background but iOS kills it (I can't treat the socket as VoIP/Location/content-news as its none of the above). Hence I am thinking of how to support APNS in the server. In other words, even if I can't do GCM for Android, there is still a way to receive alarms. No such joy for iOS users.
The problem is that like I described above, I won't be hosting the server. The users of the app will own their own server.
Given this, is there any way to support push notifications in IOS without requiring everyone who has their own servers to have apple developer accounts? I assume I can't give my certificates to them either as that would compromise my account.
Thanks

Resources