Skip to content

Removed direct reference of ktx to be in-line with the other android … #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firebase-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ kotlin {

val androidMain by getting {
dependencies {
api("com.google.firebase:firebase-config-ktx")
api("com.google.firebase:firebase-config")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ package dev.gitlive.firebase.remoteconfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException
import com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchThrottledException
import com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
import kotlinx.coroutines.tasks.await
import com.google.firebase.ktx.Firebase as AndroidFirebase
import com.google.firebase.remoteconfig.FirebaseRemoteConfig as AndroidFirebaseRemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo as AndroidFirebaseRemoteConfigInfo
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings as AndroidFirebaseRemoteConfigSettings

actual val Firebase.remoteConfig: FirebaseRemoteConfig
get() = FirebaseRemoteConfig(AndroidFirebase.remoteConfig)
get() = FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance())

actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig =
FirebaseRemoteConfig(AndroidFirebase.remoteConfig)
FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(app.android))

actual class FirebaseRemoteConfig internal constructor(val android: AndroidFirebaseRemoteConfig) {
actual val all: Map<String, FirebaseRemoteConfigValue>
Expand All @@ -29,10 +26,10 @@ actual class FirebaseRemoteConfig internal constructor(val android: AndroidFireb

actual suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) {
val settings = FirebaseRemoteConfigSettings().apply(init)
val androidSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = settings.minimumFetchIntervalInSeconds
fetchTimeoutInSeconds = settings.fetchTimeoutInSeconds
}
val androidSettings = com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(settings.minimumFetchIntervalInSeconds)
.setFetchTimeoutInSeconds(settings.fetchTimeoutInSeconds)
.build()
android.setConfigSettingsAsync(androidSettings).await()
}

Expand Down