Skip to content

How HealthBridge works in Unity

HealthBridge presents one C# API while selecting an editor, HealthKit, or Health Connect provider for the current runtime.

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
  • 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.

Gameplay or UI
HealthBridgeService / WorkoutImporter
Active IHealthProvider
Editor mock, HealthKit, or Health Connect
Task result and main-thread HealthBridgeEvents

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.

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.