feat(ios): add SLEEP_UNKNOWN support for HKCategoryValueSleepAnalysis.asleepUnspecified - #500
Open
nmidde7-ops wants to merge 1 commit into
Open
Conversation
….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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Wearables like Oura write
asleepUnspecified(value 6 inHKCategoryValueSleepAnalysis) sleep stage records to HealthKit. These records are silently dropped by this package becauseHealthConstants,SwiftHealthPlugin, andHealthDataReaderhave 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
asleepUnspecifiedsegments.Fix
Three purely additive changes, following the identical pattern already used for
SLEEP_LIGHT(value 3),SLEEP_DEEP(value 4), andSLEEP_REM(value 5):HealthConstants.swift— addSLEEP_UNKNOWNstring constantSwiftHealthPlugin.swift— register it againstHKCategoryType.sleepAnalysisHealthDataReader.swift— filter for$0.value == 6(two call sites)No existing behaviour is changed.
SLEEP_UNKNOWNalready 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_UNKNOWNto the requested types on the Dart side.