ios - ObserveSingleEvent returns old data -
i want fetch required app version number when app starts. can't right key.
i have code fetch. use observe single event because use method check required app version number. method fired when app starts check.
func getversion(completionhandler: @escaping (result<any?>) -> ()) { let ref: databasereference! = database.database().reference().child("version").child("ios") ref?.observesingleevent(of: .value , with: { snapshot in if snapshot.exists() { let recent = snapshot.value as! nsdictionary print(recent) } }) }
but returning old results? have ispersistenceenabled
enabled @ appdelegate
.
this database structure:
i no results when use database.database().reference().child("version").child("ios").
snapshot.exists false when use that.
what had was: - version | ios - 1.0
and result when use database.database().reference().child("version"), namely {ios => 1.0}
. don't because old structure.
the firebase realtime database synchronizes , stores local copy of data active listeners. in addition, can keep specific locations in sync.
let scoresref = database.database().reference(withpath: "scores") scoresref.keepsynced(true)
the firebase realtime database client automatically downloads data @ these locations , keeps in sync if reference has no active listeners. can turn synchronization off following line of code.
scoresref.keepsynced(false)
haven't tried should work.
Comments
Post a Comment