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:

enter image description here

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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -