Skip to content

Commit

Permalink
fixing config issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Idrees committed Jul 18, 2022
1 parent 336d538 commit e303387
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.google.gson.annotations.SerializedName
class RemoteConfigDate(private val remoteTopic: String) {

private var remoteConfig: FirebaseRemoteConfig? = null
private val timeInMillis: Long = if (BuildConfig.DEBUG) 1L else 3600L
private val timeInMillis: Long = if (BuildConfig.DEBUG) 0L else 3600L

private fun getInstance(): FirebaseRemoteConfig? {
remoteConfig?.let {
Expand All @@ -22,6 +22,7 @@ class RemoteConfigDate(private val remoteTopic: String) {
.setMinimumFetchIntervalInSeconds(timeInMillis)
.build()
remoteConfig?.setConfigSettingsAsync(configSetting)
remoteConfig?.fetch(timeInMillis)
remoteConfig?.setDefaultsAsync(
mapOf(remoteTopic to Gson().toJson(Any()))
)
Expand All @@ -36,6 +37,7 @@ class RemoteConfigDate(private val remoteTopic: String) {
}

fun getRemoteConfig(listener: ((Any?) -> Unit)) {
getInstance()?.reset()
getInstance()?.fetchAndActivate()
?.addOnCompleteListener { task ->
if (task.isSuccessful) {
Expand Down

0 comments on commit e303387

Please sign in to comment.