Skip to main content

Programs

The Programs module returns the member's available programs and feature flags. Use this to build entitlement-driven UI -- show only the features the member is enrolled in and hide those that are not activated.


Data Model

ProgramEntitlement

FieldTypeDescription
nameString?Program name (e.g., "SmartWalking", "GymVisits").
activatedBooleanWhether the program is active for this member.
programDataProgramData?Program-specific configuration (goals, thresholds).

ProgramData

FieldTypeDescription
dailyGoalInt?Daily activity goal (general).
dailyStepsGoalInt?Daily step count target.
goalsNeededForMonthInt?Number of days the member must meet their goal per month.
dailyVisitsGoalInt?Number of facility visits expected per day.

ProgramFeature

FieldTypeDescription
nameString?Feature identifier (e.g., "fit_at_home", "self_report").
activatedBooleanWhether this feature is enabled for the member.

Get Available Programs

Returns the list of programs the member is eligible for, along with their activation status and configuration.

lifecycleScope.launch {
try {
val programs = AFCore.programs().getAvailablePrograms()

programs.forEach { program ->
val status = if (program.activated) "Active" else "Inactive"
Log.d("Programs", "${program.name}: $status")

// Use program goals to configure step counters or visit trackers
program.programData?.let { data ->
Log.d("Programs", " Daily steps goal: ${data.dailyStepsGoal}")
Log.d("Programs", " Monthly goal days: ${data.goalsNeededForMonth}")
}
}
} catch (e: Exception) {
showError("Could not load programs: ${e.message}")
}
}

Get Available Features

Returns feature flags that control which UI sections to show. Use this to conditionally render features like Fit@Home, Self-Report, or SmartWalking.

lifecycleScope.launch {
val features = AFCore.programs().getAvailableFeatures()

// Build a set of active feature names for quick lookups
val activeFeatures = features
.filter { it.activated }
.mapNotNull { it.name }
.toSet()

// Conditionally show UI sections
showFitAtHome = "fit_at_home" in activeFeatures
showSelfReport = "self_report" in activeFeatures
showSmartWalking = "smart_walking" in activeFeatures
}

Best Practices

  • Cache feature flags on sign-in and refresh periodically. Avoid calling getAvailableFeatures() on every screen transition.
  • Default to hidden when a feature flag is missing or the call fails. This prevents exposing features the member is not entitled to.
  • Use programData to configure goals. For example, set a SmartWalking step counter target from dailyStepsGoal rather than hardcoding a value.

Quick Reference

// Android
AFCore.programs().getAvailablePrograms() // List<ProgramEntitlement>
AFCore.programs().getAvailableFeatures() // List<ProgramFeature>