gpt4 book ai didi

ios - 使用 Firebase RemoteConfiguration 我无法覆盖 .plist 文件中的默认配置

转载 作者:行者123 更新时间:2023-11-30 12:17:05 25 4
gpt4 key购买 nike

我正在运行RemoteConfig如下所示在项目上获取,以尝试获取我在服务器上设置为 true 的测试配置参数。

我的应用程序包中还有一个默认配置 plist 文件。

获取成功后,我调用activateFetched,但它似乎获取了我在默认plist文件中获得的值,该值设置为false .

知道为什么吗?

这是默认的 plist 文件:

enter image description here

这是代码:

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
}
}

这是我如何称呼上面的:

override func viewDidLoad() {
super.viewDidLoad()
remoteConfig = RemoteConfig.remoteConfig()
let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: true)
remoteConfig.configSettings = remoteConfigSettings!
remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")
fetchConfig()
}

最佳答案

在我看来,你做的一切都是正确的。我会做两件事:

  1. 注意拼写错误 - 如果您在 Firebase 控制台或 testParameterConfigKey 中错误地设置了 key 名称,这会让您陷入困境(并且很可能会给您一个错误的结果)值)

  2. 不要从 bool 值开始测试。如果您意外地使用了错误的 key 或未加载 plist 文件或类似的错误,那么通常会在代码中为您提供“错误”值。然后您无法知道您是否确实获得了默认值,或者您是否获得了被解释为 false 的空值。相反,从字符串开始。为其指定默认值“Hello”,然后尝试在控制台中将其更改为“Goodbye”。这至少应该可以帮助您消除设置问题。

关于ios - 使用 Firebase RemoteConfiguration 我无法覆盖 .plist 文件中的默认配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45282952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com