Firebase RemoteConfig 是否继续获取?
Does Firebase RemoteConfig keep fetching?
我在初始 ViewController viewDidLoad 中加载了以下代码。它最初工作正常。但它不应该每 10 秒查找一次更改吗?
当我在 Firebase 中对配置值进行更新并发布时,我没有在应用程序中看到它。我 运行 处于调试模式,因此限制不是问题。
如果我重新启动应用程序,我会看到新值。由于间隔设置为 10 秒,我不应该在应用 运行 时看到更新吗?
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
}
知道为什么没有更新吗?
您应该改用 scheduledTimer
。
/// Fetches Remote Config data and sets a duration that specifies how long config data lasts.
/// Call activateFetched to make fetched data available to your app.
/// @param expirationDuration Duration that defines how long fetched config data is available, in
/// seconds. When the config data expires, a new fetch is required.
/// @param completionHandler Fetch operation callback.
open func fetch(withExpirationDuration expirationDuration: TimeInterval, completionHandler: FirebaseRemoteConfig.FIRRemoteConfigFetchCompletion? = nil)
fetch(withExpirationDuration: interval)
就是取数据有超时时间,也就是你的间隔。
let interval: TimeInterval = 10
Timer.scheduledTimer(timeInterval: interval,
target: self,
selector: #selector(updateConfig),
userInfo: nil,
repeats: true)
func updateConfig() {
let rc = FIRRemoteConfig.remoteConfig()
FIRRemoteConfig.remoteConfig().fetch { (status, error) in
guard error == nil else {
//handle error here
return
}
FIRRemoteConfig.remoteConfig().activateFetched()
let test = rc["key1"].stringValue //this runs only once
}
}
我在初始 ViewController viewDidLoad 中加载了以下代码。它最初工作正常。但它不应该每 10 秒查找一次更改吗?
当我在 Firebase 中对配置值进行更新并发布时,我没有在应用程序中看到它。我 运行 处于调试模式,因此限制不是问题。
如果我重新启动应用程序,我会看到新值。由于间隔设置为 10 秒,我不应该在应用 运行 时看到更新吗?
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
}
知道为什么没有更新吗?
您应该改用 scheduledTimer
。
/// Fetches Remote Config data and sets a duration that specifies how long config data lasts.
/// Call activateFetched to make fetched data available to your app.
/// @param expirationDuration Duration that defines how long fetched config data is available, in
/// seconds. When the config data expires, a new fetch is required.
/// @param completionHandler Fetch operation callback.
open func fetch(withExpirationDuration expirationDuration: TimeInterval, completionHandler: FirebaseRemoteConfig.FIRRemoteConfigFetchCompletion? = nil)
fetch(withExpirationDuration: interval)
就是取数据有超时时间,也就是你的间隔。
let interval: TimeInterval = 10
Timer.scheduledTimer(timeInterval: interval,
target: self,
selector: #selector(updateConfig),
userInfo: nil,
repeats: true)
func updateConfig() {
let rc = FIRRemoteConfig.remoteConfig()
FIRRemoteConfig.remoteConfig().fetch { (status, error) in
guard error == nil else {
//handle error here
return
}
FIRRemoteConfig.remoteConfig().activateFetched()
let test = rc["key1"].stringValue //this runs only once
}
}