简体   繁体   English

如何知道远程配置在 android firebase 中工作

[英]How to know remote config working in android firebase

I am learning firebase remote config.我正在学习 firebase 远程配置。 I am trying to set time interval to fetch value from firebase.我正在尝试设置时间间隔以从 firebase 中获取值。 I want to know that value is fetched or not.我想知道是否获取了值。 So how can I achieved this through in code?那么我怎样才能通过代码实现呢?

object RemoteConfigFb {

    private val remoteConfig: FirebaseRemoteConfig by lazy {
        Firebase.remoteConfig
    }

    fun initialize() {
        val configSettings = remoteConfigSettings {
            minimumFetchIntervalInSeconds = 60 * 5 // 5 minutes
        }
        remoteConfig.setConfigSettingsAsync(configSettings)
    }

    fun refreshConfig() {
        remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
            logD("fetchAndActivate success: ${task.isSuccessful}")

            if (task.isSuccessful) {
               // welcome message
            }
        }
    }
} 

I am calling below method to button click我正在调用下面的方法来单击按钮

remoteConfig.getString("Welcome message")

I am getting new value in every 5 minutes.我每 5 分钟就会获得新的价值。 My main question is how to track that value is fetched or not and even I want to check fetch is fail or not.我的主要问题是如何跟踪该值是否被获取,甚至我想检查获取是否失败。 So how can I determine all this in this code.那么我怎样才能在这段代码中确定所有这些。 Thanks谢谢

remoteConfig.info.lastFetchStatus

I am using above code to get status.我正在使用上面的代码来获取状态。 Thanks @ ocos for your great advice.感谢@ocos的好建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM