首页 > 解决方案 > 未收到远程配置回调 - iOS

问题描述

伙计们,我对此感到厌倦,我已经在演示项目中尝试过这些东西,它工作正常并且能够获取远程配置值。

但是在我的项目中,当我集成远程配置设置时,我没有得到 fetch 方法的回调。

这是我所做的代码。

override func viewDidLoad() {
    remoteConfig = RemoteConfig.remoteConfig()

    let settings = RemoteConfigSettings()
    settings.minimumFetchInterval = 0
    remoteConfig.configSettings = settings

    remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")
    self.getRemoteConfig()
}
func getRemoteConfig() {

    print(remoteConfig["colorPrimaryDark"].stringValue ?? "NOT FOUND")

    remoteConfig.fetch(withExpirationDuration: TimeInterval(10)) { (status, error) in

        if status == .success {
            print("Config fetched!")
            self.remoteConfig.activate(completionHandler: { (error) in
              // ...
            })
        }
        else {
            print("Config not fetched")
            print("Error: \(error?.localizedDescription ?? "No error available.")")
        }
        self.PrintConfigValues()
    }

}

func PrintConfigValues() {
    print("REMOTE VALUES : ----- \(remoteConfig["colorPrimaryDark"].stringValue ?? "NOT FOUND")")
}

为什么我没有得到 fetch 方法的回调的可能性是什么。请帮帮我。

标签: iosswiftfirebasefirebase-remote-config

解决方案


我希望你已经在你的Appdelegate文件中实现了这一行:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    FIRApp.configure()

    return true
}

推荐阅读