Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
This article pertains to:
Status
colourBlue
titleLEGACY API (V1)
Status
colourGreen
titleINFORM (V2)

...

How are Apple Health sleep records processed by the Validic API?

iOS Native SDK 1.16.2 introduces the new sleep API that Apple introduced in iOS 16.

iOS Native SDK 1.16.3 improves upon our handling to also cover manually entered sleep records.

For those who wear the Apple Watch to bed for sleep tracking purposes, watchOS 9 and iOS 16 bring new functionality – sleep stages. Our Apple Health integration is available to sync the following sleep stage details to Validic:

...

Apple’s guidelines specify that sleep should be defined by in-bed time periods, with sleep stages (light, deep, REM, etc) occurring during an in-bed time range. The Apple Watch follows this approach and

Validic’s processing of sleep data assumes that the sleep stages will overlap with an in-bed record, except in the case of Apple Watches (see below).

Each 3rd party source in Apple Health will report a separate sleep record to Validic. You will be able to tell the original source of the data by looking at the sourcing information in the Validic sleep record.

What’s the deal with Apple Watches?

Please note that Apple allows for a variety of 3rd party sources to report sleep data into the Health app and some sources may not follow Apple’s guidance on sleep reporting. In fact, the Apple Watch WatchOS 11 update from Apple does not follow their own guidance. Apple’s brief explanation of this situation can be found here. Apple may adjust their processing in a future WatchOS version, however, for now WatchOS 11 does not properly report sleep in-bed or sleep samples in Inform.

Info

Be aware that Validic is planning a mobile SDK update to handle sleep from WatchOS 11 Apple Watches.

We plan to determine the sleep duration by looking for contiguous sleep samples. If there is more than a 10 minute gap after sleep samples have been received, we assume the user is no longer asleep and all contiguous sleep samples will be summarized in a single Inform sleep record. Therefore, you may receive

...

more than one sleep record per night depending on how active the user is in between sleep samples.

While not perfect, this will allow us to process WatchOS 11 sleep even though the Apple Watch does not report in-bed times.

Please stay tuned to our release notes for details when that release drops.

Also, if a 3rd party source does not report sleep with in-bed ranges then you will not receive the sleep records from that source. So keep in mind that you may receive sleep records from some 3rd party sources but not others.

Important Considerations:

  1. In Apple Health, Sleep samples cannot be edited; they can only be deleted and re-created with different information.

  2. Validic does not currently report any deletion events. Sleep samples that have already been processed will not be deleted from Validic if they are deleted from Apple Health.

  3. When In-Bed samples are reported by a source, the In-Bed samples will generate new sleep records in Validic. The In-Bed start and end time will correspond to the start and end time on the Validic sleep record.Only

  4. When In-Bed samples are not reported by a source, and the source is Apple Watch, then contiguous sleep samples will generate new sleep records in Validic. The start and end times of the contiguous group of samples will correspond to the start and end time on the Validic sleep record.

  5. Total awake duration (awake_duration) does not contribute to time in bed (in_bed_duration) as this is treated as a period of time when the user got out of bed.

  6. When In-Bed samples are not reported by a source, and the source is 3rd-party (i.e., not Apple Watch), then the sleep stages will not be reported in Validic.

  7. With the exception of Apple Watch, only sleep stages that correspond with an in-bed time will be processed in Validic. If a user manually adds a sleep stage (e.g., Asleep time or Awake time) without an in-bed sample, the sleep stages will not be reported in Validic.

    1. This is inline with Apple’s guidelines for how sleep should be reported in Apple Health, but all 3rd party sources may not comply with the their guidelines.