so I set Firebase remote config default in my iOS like this:
let remoteConfig = RemoteConfig.remoteConfig()
// set remote config default value
let defaultRemoteConfig : [String:NSObject] = [
"number_of_recommended_events_to_show_per_page" : 15 as NSObject
]
remoteConfig.setDefaults(defaultRemoteConfig)
// Activate and refetch remote config data.
// I use 'Load Value for next time' loading strategy
remoteConfig.activate()
remoteConfig.fetch()
and then I want to get the value from remote like this
// get the value from remote config
let numberOfDocumentsPerQuery = remoteConfig.configValue(forKey: "number_of_recommended_events_to_show_per_page").numberValue as! Int
I need the value in Integer format, but it crash when I cast it to Int
like that
here is how I set the value in the console
why is it nil ? how to fix this ?
fetchAndActivate
your config before trying to access a value? And don't use force unwrap!
operator. – Shun