Unity quickstart
Before you begin
Section titled “Before you begin”Use Unity 6. The HealthBridge package supports iOS HealthKit and Android Health Connect; editor and desktop runs use the mock provider rather than real health records.
Install and configure
Section titled “Install and configure”- Import the supplied HealthBridge
.unitypackageinto the Unity project. Unity resolves the required Newtonsoft JSON dependency on first import. - Let script compilation finish. The HealthBridge Setup Wizard should open. If it does not, select Window > HealthBridge > Setup Wizard.
- In the wizard, create a HealthBridge Settings asset and optional editor test data. Select only the data types your feature needs.
- Review the settings later at Edit > Project Settings > HealthBridge.
For Android, add a HealthBridgeInitializer component to a scene GameObject,
assign the settings asset, and enable Initialize On Awake. It supplies the
activity lifecycle the Android provider needs.
Initialize from code
Section titled “Initialize from code”For platforms other than Android, use automatic initialization:
using HealthBridge;using UnityEngine;
public class HealthBridgeBootstrap : MonoBehaviour{ private async void Start() { var ready = await HealthBridgeService.AutoInitializeAsync(); Debug.Log(ready ? "HealthBridge is ready" : "HealthBridge is not ready"); }}On iOS, await HealthBridgeService.PrewarmAsync() before a permission flow can
reduce first-use native setup work. It is a no-op on other platforms.
Verify in the editor
Section titled “Verify in the editor”- Create or copy the Health Data Review sample into your project.
- Enter Play mode and use the sample’s Workouts, Heart Rate, Health Data, and Write tabs.
- Confirm that initialization succeeds and mock data is shown.
The mock provider is for development only. Continue with mobile platform setup before treating an editor result as device validation.
Read data
Section titled “Read data”Use a short unified type ID with HealthDataQuery:
using HealthBridge;using HealthBridge.Data;
var query = new HealthDataQuery("steps", daysBack: 7, maxRecords: 100);var result = await HealthBridgeService.ReadDataAsync(query);
foreach (var sample in result.Samples) Debug.Log($"{sample.DataTypeId}: {sample.StartDateTime}");Common type IDs include steps, sleep, weight, calories, distance,
nutrition, hydration, and exercise. The selected settings permissions, not
just the code, determine which platform data can be requested.
Important permission behavior
Section titled “Important permission behavior”- The OS prompt is shown during initialization. Present your own explanation to the player before calling it.
- iOS may report initialization as complete even when access was denied; Apple does not expose per-type read grants. Denied reads can appear as empty data.
- Android initialization succeeds only when its core permissions are granted.
Subscribe to
HealthBridgeEvents.OnPermissionsResolvedfor the granted and denied details.
Next: configure iOS and Android or troubleshoot setup.
