Is there a way to manually and immediately refresh the Firebase cache, using the iOS SDK, to pull down the latest data (assuming you are online)? For example, if I made some changes to my data on Firebase, I want my app to reflect that immediately, but with persistence turned on, it usually takes a few restarts of the app.
I recently turned on persistence in my app like so:
Firebase.defaultConfig().persistenceEnabled = true
It worked great, but now my app doesn't refresh it's data very often even with an internet connection. I'm using the offline capabilities mentioned here.
I had the same problem with persistence and here are two options solving it:
1) Keep using observeSingleEventOfType
but setting ref.keepSynced(true)
. This won't listen to changes happening in your data but it refreshes data once this code is executed. I've chosen this option for my FAQ section which just needs to update once when the screen is opened (viewDidLoad).
2) Use observeEventOfType
. This will always keep your data in sync and will execute again as soon as your data changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With