0

I've recently turned on offline persistence for my Firebase database in my iPhone app:

FIRDatabase.database().persistenceEnabled = true

When reading the data from a database reference then going into the Firebase console and deleting that data, the next time I read from that reference the deleted entries are still there. Is this a side effect of having persistence enabled in my Firebase app? I'm reading the data in this manner:

let petRef = FIRDatabase.database().reference().child("pets").child(pet)
petRef.observeSingleEvent(of: .value, with: { snapshot in
   ...

Should I always use .keepSynced(true) on references to not have this happen?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
MarksCode
  • 8,074
  • 15
  • 64
  • 133
  • 2
    Firebase Database's disk persistence doesn't mix well with single-value event listeners. See [my answer to this question](http://stackoverflow.com/questions/34486417/firebase-offline-capabilities-and-addlistenerforsinglevalueevent) for details. In this case `keepSynced(true)` might work, but as a general rule: use regular `observe` listeners when using disk persistence. – Frank van Puffelen Apr 11 '17 at 05:53
  • Thanks Frank. Is using `keepSynced(true)` expensive? I plan on having 2 or 3 references synced for each user of my application. – MarksCode Apr 11 '17 at 06:03
  • Keeping a location synced is as expensive as the data changes at that location, plus some minor overhead for attaching the listener. – Frank van Puffelen Apr 11 '17 at 07:17

0 Answers0