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
| Field | Type | Description |
|---|---|---|
name | String? | Program name (e.g., "SmartWalking", "GymVisits"). |
activated | Boolean | Whether the program is active for this member. |
programData | ProgramData? | Program-specific configuration (goals, thresholds). |
ProgramData
| Field | Type | Description |
|---|---|---|
dailyGoal | Int? | Daily activity goal (general). |
dailyStepsGoal | Int? | Daily step count target. |
goalsNeededForMonth | Int? | Number of days the member must meet their goal per month. |
dailyVisitsGoal | Int? | Number of facility visits expected per day. |
ProgramFeature
| Field | Type | Description |
|---|---|---|
name | String? | Feature identifier (e.g., "fit_at_home", "self_report"). |
activated | Boolean | Whether 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.
- Android (Kotlin)
- iOS (Swift)
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}")
}
}
do {
let programs = try await AFCore.shared.programs().getAvailablePrograms()
for program in programs {
let status = program.activated ? "Active" : "Inactive"
print("\(program.name ?? "Unknown"): \(status)")
if let data = program.programData {
print(" Daily steps goal: \(data.dailyStepsGoal ?? 0)")
print(" Monthly goal days: \(data.goalsNeededForMonth ?? 0)")
}
}
} catch {
showError("Could not load programs: \(error)")
}
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.
- Android (Kotlin)
- iOS (Swift)
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
}
let features = try await AFCore.shared.programs().getAvailableFeatures()
let activeFeatures = Set(
features.filter { $0.activated }.compactMap { $0.name }
)
showFitAtHome = activeFeatures.contains("fit_at_home")
showSelfReport = activeFeatures.contains("self_report")
showSmartWalking = activeFeatures.contains("smart_walking")
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
programDatato configure goals. For example, set a SmartWalking step counter target fromdailyStepsGoalrather than hardcoding a value.
Quick Reference
- Android (Kotlin)
- iOS (Swift)
// Android
AFCore.programs().getAvailablePrograms() // List<ProgramEntitlement>
AFCore.programs().getAvailableFeatures() // List<ProgramFeature>
// iOS
try await AFCore.shared.programs().getAvailablePrograms()
try await AFCore.shared.programs().getAvailableFeatures()