Movement Health
The Movement Health module integrates with movr, a partner SDK that provides guided routines and short movement exercises ("movement snacks") throughout the day. AFCore handles registration and session submission; the movr SDK must also be installed in your app to deliver the actual movement content.
How It Works
- Check registration -- Call
isMovrProfileRegistered()to determine if the member is already linked to movr. - Register -- If not registered, call
registerMovrProfile()to create the association. - Submit sessions -- After the member completes routines in movr, call
submitMovrSessions()to report the count to the server. Completed sessions appear in the member's Activities history.
Check Registration Status
- Android (Kotlin)
- iOS (Swift)
lifecycleScope.launch {
val registered = AFCore.movementHealth().isMovrProfileRegistered()
if (registered) {
showMovrContent()
} else {
showRegistrationPrompt()
}
}
let registered = try await AFCore.shared.movementHealth().isMovrProfileRegistered()
if registered {
showMovrContent()
} else {
showRegistrationPrompt()
}
Register
Link the member's account with movr. Call this once during onboarding or when the member first accesses Movement Health.
- Android (Kotlin)
- iOS (Swift)
lifecycleScope.launch {
val success = AFCore.movementHealth().registerMovrProfile()
if (success) {
showSuccess("Movement Health activated")
showMovrContent()
} else {
showError("Could not activate Movement Health")
}
}
let success = try await AFCore.shared.movementHealth().registerMovrProfile()
if success {
showSuccess("Movement Health activated")
showMovrContent()
} else {
showError("Could not activate Movement Health")
}
Submit Sessions
Report completed movement sessions to the server. Call this after the member finishes routines in the movr SDK.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sessions | Int | Yes | Number of completed sessions to report. |
- Android (Kotlin)
- iOS (Swift)
lifecycleScope.launch {
val result = AFCore.movementHealth().submitMovrSessions(sessions = completedCount)
if (result.status) {
showSuccess("$completedCount sessions recorded")
} else {
showError("Could not submit sessions: ${result.statusMessage}")
}
}
let result = try await AFCore.shared.movementHealth().submitMovrSessions(
sessions: Int32(completedCount)
)
if result.status {
showSuccess("\(completedCount) sessions recorded")
} else {
showError("Could not submit sessions: \(result.statusMessage ?? "Unknown error")")
}
Best Practices
- Prompt registration on first access. Check
isMovrProfileRegistered()and show a clear onboarding screen explaining what Movement Health provides. - The movr SDK is required. AFCore only handles registration and session reporting. The movr SDK delivers the actual movement routines. Ensure it is installed and initialized in your app.
- Submit sessions promptly. Report completed sessions as soon as the member finishes, rather than batching, so their activity history stays current.
- Show progress. Use streaks, progress rings, or daily summaries to keep members engaged with their movement goals.
Quick Reference
- Android (Kotlin)
- iOS (Swift)
// Android
AFCore.movementHealth().isMovrProfileRegistered()
AFCore.movementHealth().registerMovrProfile()
AFCore.movementHealth().submitMovrSessions(sessions)
// iOS
try await AFCore.shared.movementHealth().isMovrProfileRegistered()
try await AFCore.shared.movementHealth().registerMovrProfile()
try await AFCore.shared.movementHealth().submitMovrSessions(sessions:)