Remote Config values fall back to default values after a few hours
We have an iOS app that relies heavily on Firebase Remote Config to display some of the UI options. I set some user parameters in Firebase analytics, then do a fetch() on app startup.
Upon app launch, the values are fetched correctly. After running in the background for a few hours, bring app to foreground. The remote config values fallback to default ones.
Workaround - kill app and relaunch
Logs pasted below. It looks like when fetch() got called again, it fetched default values somehow
(Instabug Logs - Info) 16-01 18:05:04.646 remoteConfig["timeline_number_of_days"]: Optional(2)) --> should have been 30 instead of 2
(Instabug Logs - Info) 16-01 18:05:04.642 remoteConfig["remote_log_enabled"]: true)
(Instabug Logs - Info) 16-01 18:05:04.641 remoteConfig["special_needs_list"]: Optional("") -> should not be empty
(Instabug Logs - Info) 16-01 18:05:04.640 The data couldn鈥檛 be read because it isn鈥檛 in the correct format.
(Instabug Logs - Info) 16-01 18:05:04.639 remoteConfig["role_list"]: Optional("") -> should not be empty
(Instabug Logs - Info) 16-01 18:05:04.637 The data couldn鈥檛 be read because it isn鈥檛 in the correct format.
(Instabug Logs - Info) 16-01 18:05:04.598 remoteConfig["show_developer_options"]: false) --> should have been true
(Instabug Logs - Info) 16-01 18:05:04.588 FirebaseRemoteConfig: Config fetched!
var properties : [String: String] = [:]
properties["id"] = userAccount.userId
let subscriptionId = userAccount.subscriptions.first?.getId() ?? ""
properties["subscriptionId"] = subscriptionId
self.firAnalytics.setUserProperties(properties: properties)
self.fetch()
private func fetch() {
var duration: TimeInterval = 0
if Constants.Production {
duration = 60 * 60 * 6
}
remoteConfig.fetch(withExpirationDuration: duration) { (status, error) in
if status == .success {
log(tag: self.Tag, "Config fetched!")
self.remoteConfig.activate(completionHandler: { [unowned self] _ in
self.writeToSettings() //here i store fetched remote config values locally
})
} else {
log(tag: self.Tag, "Config not fetched! Error: \(String(describing: error?.localizedDescription))")
}
}
}
I found a few problems with this issue:
Hi..thanks for reporting. Default values should only be available until a fetch happens. Are you seeing empty/zero values or indeed your original defaults? Would be great if you could provide verbose logs https://firebase.google.com/docs/reference/ios/firebasecore/api/reference/Classes/FIRConfiguration#/c:objc(cs)FIRConfiguration(im)setLoggerLevel:
Hi, Thank you for getting back to me. I do see empty/zero values for couple of the parameters - role_list and special_needs_list in the logs above. For the rest, it seems like it returns default values. For eg, for timeline_number_of_days, it returns 2(default value) instead of 30. The rest of the parameters are boolean values- for which it returns false.
Hope this helps
Thanks. Can you provide verbose logs as mentioned above? That would greatly help.
Thanks for the fast response.
That's going to be kind of hard - since I don't see this in the debug environment.
I have to keep the app running in the background for a few hours, sometimes overnight - before the settings get screwed up. So viewing them on XCode console is hard.
Going through the documentation for Firebase logging - "The messages are logged both to the Xcode console and to the device鈥檚 log." What does logging to "device's log" mean ?
In this case logging to the device means what FIRLogger does, which is pretty much NSLog. It's going to be pretty impractical for you to give us hours of logs, so let's explore other options first.
Though it takes a long time to reproduce the issue, do you think you could upload a sample project that repros the issue?
Briefly, here is what I am doing:
I created a user property "id"
I set this id in Firebase Analytics
call remote config fetch() - getting values as expected
Run app in background for a few hours. Bring app to foreground. fetch() gets called again - this time with the wrong values. (my fetch() call is tied to user login - if firebase credentials expire during the time app is running in the background, we refresh credentials when app comes to the foreground, then call remote config fetch() )
I will try to get a sample project to you, however it will take me a few weeks. Please bear with me.
Thanks!
Thanks, a sample project and/or logs filtered by [Firebase/RemoteConfig] or by I-RCN* will help. That helps us deduce the exact time the fetch and activate if any happened.
Hey @shalinipk. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@shalinipk if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
Most helpful comment
Briefly, here is what I am doing:
I created a user property "id"
I set this id in Firebase Analytics
call remote config fetch() - getting values as expected
Run app in background for a few hours. Bring app to foreground. fetch() gets called again - this time with the wrong values. (my fetch() call is tied to user login - if firebase credentials expire during the time app is running in the background, we refresh credentials when app comes to the foreground, then call remote config fetch() )
I will try to get a sample project to you, however it will take me a few weeks. Please bear with me.
Thanks!