2

In my firebase database I use persistence to cache the data, but this give me a problem, because some of my data needs to be loaded from the database when the app loads and not from tha cached data. I have a tableview where the data from the database is shown, it needs to update with the database and not look for the saved data in the tableview. Right now I am using

 self.ref?.child(u.uid).observe(.value, with: { (snapshot) in
   print(offersnapshot)
})

to get the data from the data from the server. But right now the app needs to restart, before the data are updated.

KENdi
  • 7,576
  • 2
  • 16
  • 31
Lasse Bickmann
  • 133
  • 3
  • 11
  • The code you share sets up a listener and should (also) be called with the live version from the server. If you have a cached value for that reference and a network connection, the completion handler may fire twice: once for the cached version and once (if it is different) for the version from the server. – Frank van Puffelen Nov 13 '17 at 14:55

1 Answers1

1

From the info you provided i think the problem is you did not enable the syncing of firebase cache data with the firebse server database. try this:

let scoresRef = Database.database().reference(withPath: "rootNode")
scoresRef.keepSynced(true)
Y_Y
  • 331
  • 1
  • 6