How HealthBridge works in Unity
HealthBridge presents one C# API while selecting an editor, HealthKit, or Health Connect provider for the current runtime.
Runtime layers
Section titled “Runtime layers”| Layer | Purpose |
|---|---|
HealthBridgeService |
Static entry point and active-provider owner |
IHealthProvider |
Common read, write, workout, monitoring, and capability contract |
IWorkoutRouteProvider |
Optional workout-route extension |
IHealthDeleteProvider |
Optional record-deletion extension |
HealthBridgeSettings |
Project-owned permissions and platform configuration |
HealthDataTypeRegistry |
Unified IDs, support, permission mapping, and write metadata |
HealthBridgeEvents |
Main-thread lifecycle and operation events |
WorkoutImporter |
Higher-level workout import and progress flow |
Provider selection
Section titled “Provider selection”- Editor:
EditorHealthProvider. - iOS device: HealthKit provider.
- Android device: Health Connect provider created by
HealthBridgeInitializer.
Editor success proves integration logic, not mobile signing, permissions, native packaging, or real records.
Data flow
Section titled “Data flow”Gameplay or UI ↓HealthBridgeService / WorkoutImporter ↓Active IHealthProvider ↓Editor mock, HealthKit, or Health Connect ↓Task result and main-thread HealthBridgeEventsAsync and event boundaries
Section titled “Async and event boundaries”Service operations return tasks. Native callbacks are marshalled to Unity’s main thread before SDK events fire or Unity objects are touched. Await tasks instead of blocking the main thread, and remove static event subscriptions when their owner is disabled.
Optional behavior
Section titled “Optional behavior”Providers advertise HealthCapability flags. Check capabilities before showing
optional write, delete, route, monitoring, or platform-specific UI.
Unsupported optional interfaces return failed result objects instead of pretending the operation succeeded.
