Skip to content

Commit

Permalink
Merge pull request #247 from brandonballinger/brandonb-ios-16-sleep-s…
Browse files Browse the repository at this point in the history
…tages

Handle new sleep stage HKCategoryValues in iOS 16
  • Loading branch information
macelai committed Dec 15, 2022
2 parents 28d8639 + 0a8f62d commit e3b6725
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,21 @@ - (void)fetchSleepCategorySamplesForPredicate:(NSPredicate *)predicate
case HKCategoryValueSleepAnalysisAsleep:
valueString = @"ASLEEP";
break;

// watchOS 9 and iOS 16 introduce Core, Deep, REM, and Awake phases of sleep.
case HKCategoryValueSleepAnalysisAsleepCore:
valueString = @"CORE";
break;
case HKCategoryValueSleepAnalysisAsleepDeep:
valueString = @"DEEP";
break;
case HKCategoryValueSleepAnalysisAsleepREM:
valueString = @"REM";
break;
case HKCategoryValueSleepAnalysisAwake:
valueString = @"AWAKE";
break;

default:
valueString = @"UNKNOWN";
break;
Expand Down
7 changes: 4 additions & 3 deletions docs/getSleepSamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
Query for sleep samples.

Each sleep sample represents a period of time with a startDate and an endDate.
the sample's value will be either `INBED` or `ASLEEP`. these values should overlap,
meaning that two (or more) samples represent a single nights sleep activity. see
[Healthkit SleepAnalysis] reference documentation
the sample's value will be either `INBED`, `ASLEEP`, or a sleep stage (`DEEP`,
`CORE`, `REM`). In bed and sleeping samples should overlap, meaning that two
(or more) samples represent a single nights sleep activity. See
[Healthkit SleepAnalysis] reference documentation.

The options object is used to setup a query to retrieve relevant samples.
The options must contain `startDate` and may also optionally include `endDate`, `ascending`, or `limit` options
Expand Down

0 comments on commit e3b6725

Please sign in to comment.