FIRRemoteConfig.activateFetched()失败

ars*_*ius 3 ios firebase swift firebase-remote-config

我已经实现了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)")
        }
    })
Run Code Online (Sandbox Code Playgroud)

小智 9

经过大量的反复试验,我想通了.问题在于到期值,将到期值设置为0秒以查看立即生效的结果!

我希望这可以为其他人节省很多时间!