I am running RemoteConfig fetch on a project as following to try fetch a test configuration parameter that I set to true on the server.
I have also a default configuration plist file on the app bundle.
After the fetch succeeds I call activateFetched but it seems to get the value that I have got in the default plist file which is set to false.
Any idea why?
Here is the default plist file:
Here is the code:
func fetchConfig() {
var expirationDuration = 3600
if remoteConfig.configSettings.isDeveloperModeEnabled {
expirationDuration = 0
}
remoteConfig.fetch(withExpirationDuration: TimeInterval(expirationDuration)) { (status, error) -> Void in
if status == .success {
print("Config fetched!")
self.remoteConfig.activateFetched() // ?? I thought that this would override the default plist file but it does not seem to do so
self.doSomething()
} else {
print("Config not fetched")
print("Error \(error!.localizedDescription)")
}
}
func doSomething() {
let status = remoteConfig.lastFetchStatus
print(status) // <-- adding a breakpoint here this is says SUCCESS
print("last fetched at: ", remoteConfig.lastFetchTime ?? "no-value") // <--- it gives me the correct time
let remoteParamValue = remoteConfig[testParameterConfigKey].boolValue
if remoteParamValue {
print("true")
} else{
print("false") // <--- it always goes here even if the test_parameter in the remote console is set to true
}
}
Here is how I call the above:
override func viewDidLoad() {
super.viewDidLoad()
remoteConfig = RemoteConfig.remoteConfig()
let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: true)
remoteConfig.configSettings = remoteConfigSettings!
remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")
fetchConfig()
}