The feature flags module lets you enable or disable features remotely from the AppDNA Console. Flags are evaluated locally from cached config — no network call, no latency.
Check a Flag
if (AppDNA.features.isEnabled("dark_mode")) {
enableDarkMode()
}
isEnabled() returns false by default if the flag does not exist or config has not loaded.
Module Access
val features = AppDNA.features
Module Methods
| Method | Signature | Description |
|---|
isEnabled | isEnabled(flag: String): Boolean | Check if a feature flag is enabled |
getAllFlags | getAllFlags(): Map<String, Boolean> | Get all flags and their current states |
Using Flags with Experiments
Feature flags and experiments work together. Gate a feature behind a flag, then run an experiment to test its impact:
if (AppDNA.features.isEnabled("new_workout_ui")) {
val variant = AppDNA.experiments.getVariant("workout_ui_test")
when (variant) {
"compact" -> showCompactWorkoutUI()
"detailed" -> showDetailedWorkoutUI()
else -> showDefaultWorkoutUI()
}
} else {
showLegacyWorkoutUI()
}
FeatureFlagDelegate
Register a delegate to react when flags change after a config refresh:
AppDNA.features.delegate = object : FeatureFlagDelegate {
override fun onFlagChanged(flag: String, enabled: Boolean) {
if (flag == "maintenance_mode" && enabled) {
showMaintenanceScreen()
}
}
}
Full Example
import ai.appdna.sdk.AppDNA
class FeatureGate {
fun checkAccess(feature: String, onLocked: () -> Unit, onUnlocked: () -> Unit) {
if (AppDNA.features.isEnabled(feature)) {
onUnlocked()
} else {
onLocked()
}
}
}
// Usage
val gate = FeatureGate()
gate.checkAccess("ai_suggestions",
onLocked = {
AppDNA.paywall.present(
"premium_paywall", activity,
context = PaywallContext(placement = "feature_gate")
)
},
onUnlocked = {
showAISuggestions()
}
)
Feature flags are managed in the Console under Settings > Feature Flags. Toggle a flag on or off and it takes effect on the next SDK config refresh (within the TTL window, default 5 minutes).