Skip to content

feat(ios): add SLEEP_UNKNOWN support for HKCategoryValueSleepAnalysis.asleepUnspecified - #500

Open
nmidde7-ops wants to merge 1 commit into
carp-dk:mainfrom
nmidde7-ops:feat/sleep-unknown-asleep-unspecified
Open

feat(ios): add SLEEP_UNKNOWN support for HKCategoryValueSleepAnalysis.asleepUnspecified#500
nmidde7-ops wants to merge 1 commit into
carp-dk:mainfrom
nmidde7-ops:feat/sleep-unknown-asleep-unspecified

Conversation

@nmidde7-ops

Copy link
Copy Markdown

Problem

Wearables like Oura write asleepUnspecified (value 6 in HKCategoryValueSleepAnalysis) sleep stage records to HealthKit. These records are silently dropped by this package because HealthConstants, SwiftHealthPlugin, and HealthDataReader have no handling for value 6.

The result: apps using this package report sleep totals that are consistently short compared to what Apple Health and Oura show — the missing time is exactly the asleepUnspecified segments.

Fix

Three purely additive changes, following the identical pattern already used for SLEEP_LIGHT (value 3), SLEEP_DEEP (value 4), and SLEEP_REM (value 5):

  1. HealthConstants.swift — add SLEEP_UNKNOWN string constant
  2. SwiftHealthPlugin.swift — register it against HKCategoryType.sleepAnalysis
  3. HealthDataReader.swift — filter for $0.value == 6 (two call sites)

No existing behaviour is changed. SLEEP_UNKNOWN already exists in the Dart enum (HealthDataType.SLEEP_UNKNOWN) but was unreachable because the native layer never read it.

Testing

Verified on device with an Oura Ring connected to Apple Health — sleep total in app now matches Apple Health and Oura app after adding HealthDataType.SLEEP_UNKNOWN to the requested types on the Dart side.

….asleepUnspecified

Oura and other wearables write asleepUnspecified (value 6) sleep stage
records to HealthKit. These were silently dropped because HealthConstants,
SwiftHealthPlugin, and HealthDataReader had no case for value 6.

Add SLEEP_UNKNOWN constant, register it against HKCategoryType.sleepAnalysis,
and filter for $0.value == 6 — following the identical pattern used by
SLEEP_LIGHT (3), SLEEP_DEEP (4), and SLEEP_REM (5).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant