Read health data
HealthBridge returns HealthDataReadResult with typed HealthDataSample
subclasses where the public API supports them.
Query a type
Section titled “Query a type”var query = new HealthDataQuery( "steps", daysBack: 7, maxRecords: 100);
HealthDataReadResult result = await HealthBridgeService.ReadDataAsync(query);
if (!result.Success){ // Show a recoverable error. return;}
foreach (HealthDataSample sample in result.Samples){ if (sample is StepsSample steps) { long count = steps.Count; // Update a transient view model. }}Queries clamp daysBack to 1–90 and maxRecords to at least one.
Typed and generic samples
Section titled “Typed and generic samples”Prefer typed models such as:
StepsSampleSleepSampleWeightSampleCaloriesSampleDistanceSampleNutritionSampleHydrationSample
For another registry-backed type, use GetValue<T>(key) on the base sample.
There is no universal Value property.
Inspect the registry
Section titled “Inspect the registry”Before generating dynamic UI, use HealthDataTypeRegistry to inspect display
name, category, platform support, public API status, permission mappings, and
write support.
A registry row can exist for permission configuration without a typed public read/write model. Check public API status and provider capability.
Empty and partial results
Section titled “Empty and partial results”Success=false: show a recoverable error state.- Successful empty result: show a normal empty state.
- Missing generic value: keep it unavailable.
- iOS empty result: do not infer permission or absence of records.
