diff --git a/JetNews/app/src/main/java/com/example/jetnews/ui/MainActivity.kt b/JetNews/app/src/main/java/com/example/jetnews/ui/MainActivity.kt index bd6d2ac0bd..ae837c6d3a 100644 --- a/JetNews/app/src/main/java/com/example/jetnews/ui/MainActivity.kt +++ b/JetNews/app/src/main/java/com/example/jetnews/ui/MainActivity.kt @@ -17,12 +17,16 @@ package com.example.jetnews.ui import android.os.Bundle +import android.util.Log import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import com.example.jetnews.JetnewsApplication +import com.google.firebase.ktx.Firebase +import com.google.firebase.remoteconfig.ktx.remoteConfig +import com.google.firebase.remoteconfig.ktx.remoteConfigSettings class MainActivity : ComponentActivity() { @@ -36,5 +40,31 @@ class MainActivity : ComponentActivity() { val widthSizeClass = calculateWindowSizeClass(this).widthSizeClass JetnewsApp(appContainer, widthSizeClass) } + + // Inicializa Firebase Remote Config + val remoteConfig = Firebase.remoteConfig + val configSettings = remoteConfigSettings { + minimumFetchIntervalInSeconds = 3600 // Intervalo de fetch mínimo en segundos + } + remoteConfig.setConfigSettingsAsync(configSettings) + remoteConfig.setDefaultsAsync(mapOf( + "property_1" to "default_value_1", + "property_2" to "default_value_2" + )) + + // Realiza el fetch de los valores remotos + remoteConfig.fetchAndActivate().addOnCompleteListener { task -> + if (task.isSuccessful) { + val updated = task.result + Log.d("RemoteConfig", "Config params updated: $updated") + // Usa los valores de remoteConfig + val property1 = remoteConfig.getString("property_1") + val property2 = remoteConfig.getString("property_2") + // Actualiza la UI o lógica de negocio con estos valores + } else { + Log.w("RemoteConfig", "Fetch failed") + } + } + } }