Refresh Firebase iOS SDK cache immediately

后端 未结 1 686
無奈伤痛
無奈伤痛 2021-02-09 03:44

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 cha

1条回答
  •  长情又很酷
    2021-02-09 04:08

    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.

    0 讨论(0)
提交回复
热议问题