Koh
Koh

Reputation: 2897

Swift Remote Config: fetchAndActivate does not update local config

I am getting started with RemoteConfig on iOS with Swift and followed the tutorial to get started. I have developer mode enabled and tested the updating of config values via the Firebase console. However, the update values never get synced with the local config values.

Code:

override func viewDidLoad() {
    super.viewDidLoad()
    syncRemoteConfig()
}

fileprivate func syncRemoteConfig() {
    let remoteConfig = RemoteConfig.remoteConfig()

    #if DEBUG
        let settings = RemoteConfigSettings()
        settings.minimumFetchInterval = 0
        remoteConfig.configSettings = settings
    #endif

    remoteConfig.fetchAndActivate { (status, error) in

        let posts = remoteConfig.configValue(forKey: "posts").jsonValue as! [[String: AnyObject]]
        print(posts) // <== Always print the previous data

        if let error = error {
            print(error.localizedDescription)
        }

       //status always prints status.successUsingPreFetchedData
    }
}

Upvotes: 4

Views: 2398

Answers (1)

Paul Beusterien
Paul Beusterien

Reputation: 29562

Run pod update to at least Firebase 6.25.0.

It fixed a race condition bug in which the minimumFetchInterval might not have been applied before the fetch.

Upvotes: 1

Related Questions