I have the following code that loads in the initial ViewController viewDidLoad. It works fine initially. But shouldn't it look for changes every 10 seconds?
When I make an update to a config value in Firebase and publish, I don't see this come through in the app. I am running in debug mode so throttling isn't an issue.
If I restart the app, I see the new value. Since the interval is set to 10 seconds, shouldn't I see the update while the app is running?
let rc = FIRRemoteConfig.remoteConfig()
let interval: TimeInterval = 10
FIRRemoteConfig.remoteConfig().fetch(withExpirationDuration: interval) {
(status, error) in
guard error == nil else {
//handle error here
return
}
FIRRemoteConfig.remoteConfig().activateFetched()
let test = rc["key1"].stringValue //this runs only once
}
Any ideas why this isn't update?
You should use
scheduledTimer
instead.fetch(withExpirationDuration: interval)
is to fetch data with a timeout, that is your interval.