You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

0 D铆as
5 Hrs
15 Min
39 Seg

Dark Launches

5/17
Resources

Implementing controlled release strategies is critical to ensure a smooth user experience during mobile application updates. Using techniques such as dark launches and feature flags, developers can deploy new features in a secure and controlled manner, ensuring that all users receive updates simultaneously, regardless of their automatic update settings.

How to deploy dark launches with Firebase Remote Config?

Dark launches are a strategy that allows you to introduce new features in a hidden way, activating them remotely when necessary. This technique is especially useful when we want to ensure that all users receive an update at the same time, even those who do not have automatic updates configured on their devices.

To implement this strategy, we will use Firebase Remote Config, a tool that allows us to remotely control the behavior of our application. Let's see step by step how to configure it:

  1. Access the Firebase console and go to the Remote Config section in the Run tab.
  2. Create a new configuration with a descriptive name (for example, "isActive").
  3. Select the data type (in this case, Boolean).
  4. Add an optional description (such as "for when the new update is released").
  5. Set a default value.
  6. Save and publish the changes to make them available in production.

Configuring the ViewModel for Remote Config

Once the parameter is configured in Firebase, we need to implement the logic in our application to control this functionality. Following an MVVM architecture, we will create a dedicated ViewModel:

class MainViewModel(private val context: Context, private val application: Application) {    
 companion object { private val ACTIVE_KEY = "isActive" }    
 private val remoteConfig: FirebaseRemoteConfig = FirebaseRemoteConfig.getInstance()    
 private val _isActive = MutableStateFlow(true) val isActive: StateFlow<Boolean> get() = _isActive    
 private fun setupConfigRemote() { val configSettings = RemoteConfigSettings.Builder() .setMinimumFetchIntervalInSeconds(3600) .build()        
 remoteConfig.setConfigSettingsAsync(configSettings) remoteConfig.setDefaultsAsync(mapOf(ACTIVE_KEY to false)) }    
 private fun fetchAndActivate() { viewModelScope.launch { remoteConfig.fetchAndActivate() .addOnCompleteListener { task -> if (task.isSuccessful) { _isActive.value = remoteConfig.getBoolean(ACTIVE_KEY) } else { Toast.makeText(context, "Failed", Toast.LENGTH_SHORT).show() } } } } } } } } } } } } }}

In this code:

  • We create an ACTIVE_KEY constant that matches the parameter name in Firebase.
  • We initialize the FirebaseRemoteConfig instance.
  • We configure a StateFlow to maintain the state of the functionality.
  • We implement methods to configure and get the remote values.

The minimum refresh interval (3600 seconds) determines when the application will re-request updated values from Firebase.

Integration with the user interface

To use this configuration in our UI, we need to connect the ViewModel to our view:

// In MainActivityval mainViewModel = MainViewModel(applicationContext, application)
// In the composable function@Composablefunction FoodTrackScreen(mainViewModel: MainViewModel) { val isActive by mainViewModel.isActive.collectAsState(initial = true)    
 Column { // Regular content of the app        
 // Show new functionality only if active if (isActive) { Card { // Content of the new functionality Text("New section enabled!") } } } } } } } } }}

With this implementation, we can remotely control the visibility of new functionality without the need to launch application updates. When we decide to enable the functionality for all users, we simply change the value in Firebase Remote Config.

What are feature flags and how do they differ from dark launches?

Feature flags are a similar strategy to dark launches, but with a slightly different approach. While dark launches focus on launching updates in a controlled and simultaneous manner, feature flags are designed to turn on and off specific functionalities of our application as needed.

This technique allows us to:

  • Perform A/B testing with different groups of users
  • Quickly deactivate problematic features without the need to release an upgrade
  • Implement gradual rollouts to monitor the impact of new features
  • Customize the experience for different user segments

The technical implementation is similar to dark launches, using Firebase Remote Config or other similar tools, but with a more granular focus on controlling individual features.

Mobile app developers can leverage these strategies to minimize risks during launches and ensure a consistent, high-quality user experience. Both dark launches and feature flags are essential tools in the arsenal of any development team looking to implement modern continuous delivery practices.

Have you ever implemented these strategies in your applications? Share your experience in the comments and tell us what other techniques you use to control your releases.

Contributions 0

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?