Agenda
What is Firebase?
Android: FireBase + Kotlin Part 1 (Remote Config)
Android: FireBase + Kotlin Part 2 (Firebase Firestore)
Android: FireBase + Kotlin Part 3 (Firebase Realtime Database)
What is Firebase?
Firebase can help you tackle demanding challenges, whether you’re a developer, marketer, or product manager. Our tools work together so that mobile teams can improve app performance while gaining valuable user insights.
Build apps fast, without managing infrastructure
Firebase gives you functionality like analytics, databases, messaging and crash reporting so you can move quickly and focus on your users.
Backed by Google, trusted by top apps
Firebase is built on Google infrastructure and scales automatically, for even the largest apps.
One platform, with products that work better together
Firebase products work great individually but share data and insights, so they work even better together.
What is Remote Config?
Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. When using Remote Config, you create in-app default values that control the behavior and appearance of your app. Then, you can later use the Firebase console or the Remote Config backend APIs to override in-app default values for all app users or for segments of your user base. Your app controls when updates are applied, and it can frequently check for updates and apply them with a negligible impact on performance.
api 'com.google.firebase:firebase-config-ktx:NewestVersion'
api 'com.google.firebase:firebase-analytics-ktx:NewestVersion'
For Remote Config, Google Analytics is required for the conditional targeting of app instances to user properties, audiences, and Firebase Predictions. Make sure you enable Google Analytics in your project.
Policies and limits
Note the following policies:
- Don’t use Remote Config to make app updates that should require a user’s authorization. This could cause your app to be perceived as untrustworthy.
- Don’t store confidential data in Remote Config parameter keys or parameter values. It is possible to decode any parameter keys or values stored in the Remote Config settings for your project.
- Don’t attempt to circumvent the requirements of your app’s target platform using Remote Config.
Remote Config parameters and conditions are subject to certain limits. To learn more, see Limits on parameters and conditions.
What can I do with Remote Config?
App developers use Remote Config in many different ways to suit their unique requirements, and we encourage that. To give you an idea of the kinds of things you can do with Remote Config, this page describes some use cases with broad applicability to mobile developers.
Get the FirebaseRemoteConfig instance of the default app
Kotlin
val remoteConfig = FirebaseRemoteConfig.getInstance()
Kotlin + KTX
val remoteConfig = Firebase.remoteConfig
Get the FirebaseRemoteConfig of a given FirebaseApp
Kotlin
val remoteConfig = FirebaseRemoteConfig.getInstance(app)
Kotlin + KTX
val remoteConfig = Firebase.remoteConfig(app)
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
Set Remote Config Settings — FireBase Console
Open your project, and then select Remote Config under the Grow section from the left-hand menu.
We have to fill in the “Parameter key” and “Default value.” Finally, don’t forget to hit “Publish changes” to make our changes go live. Add the parameter with the same key as used the in-app
Get parameter values from FirebaseRemoteConfig
Kotlin
val isEnabled = remoteConfig.getBoolean("is_enabled")val fileBytes = remoteConfig.getByteArray("file_bytes")val audioVolume = remoteConfig.getDouble("audio_volume")val maxCharacters = remoteConfig.getLong("max_characters")val accessKey = remoteConfig.getString("access_key")
Kotlin + KTX
val isEnabled = remoteConfig["is_enabled"].asBoolean()val fileBytes = remoteConfig["file_bytes"].asByteArray()val audioVolume = remoteConfig["audio_volume"].asDouble()val maxCharacters = remoteConfig["max_characters"].asLong()val accessKey = remoteConfig["access_key"].asString()
Kotlin
val configSettings = FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(3600)
.setFetchTimeoutInSeconds(60)
.build()
remoteConfig.setConfigSettingsAsync(configSettings)
Kotlin + KTX
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 3600
fetchTimeoutInSeconds = 60
}
remoteConfig.setConfigSettingsAsync(configSettings)
Thanks for: