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 settingref.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.