我已经实现了 FIRRemoteConfig 并在 firebase 控制台中添加了我的第一个值。但是,当我尝试激活获取的值时,它会失败,并且我的远程值永远不可用。
let remote = FIRRemoteConfig.remoteConfig()
#if DEBUG
let expiration: TimeInterval = 0
remote.configSettings = FIRRemoteConfigSettings(developerModeEnabled: true)
#else
let expiration: TimeInterval = 24*60*60
#endif
var map = [String:NSObject]()
let defaults = RemoteSettings.defaults.keys
for key in defaults.keys {
map[key.rawValue] = defaults[key] as? NSObject
}
remote.setDefaults(map) // Have confirmed that map is valid here
remote.fetch(withExpirationDuration: expiration, completionHandler: { (status, error) in
// status always == .success, but remote.activateFetched() always returns false.
if status == .success && remote.activateFetched() {
print("applied remote settings")
} else {
print("failed to apply remote settings: \(error)")
}
})