我使用 Firebase 远程配置来比较要更新的应用程序版本,但无法获取远程配置值。
如何使用 swift 获取像数组 json 这样的值?
这就是我的价值
[
{
"version": "1.0.4",
"status": "2",
"text": "Fix Error"
}
]
Run Code Online (Sandbox Code Playgroud)
这是我的代码
获取值:
class ConstraintValues {
static let shared = ConstraintValues()
init() {
RemoteConfig.remoteConfig().setDefaults(["a":"b" as NSObject])
let debugSettings = RemoteConfigSettings()
RemoteConfig.remoteConfig().configSettings = debugSettings
}
func fetch(completetion:@escaping ( _ stringarray:String?)->()) {
RemoteConfig.remoteConfig().fetch(withExpirationDuration: 0) { (status, error) in
if let error = error {
print(error)
completetion(nil)
return
}
RemoteConfig.remoteConfig().activate()
let rc = RemoteConfig.remoteConfig().configValue(forKey: "VERSION")
do {
let json = try JSONSerialization.jsonObject(with: rc.dataValue, options: …
Run Code Online (Sandbox Code Playgroud)