Sleep onset detection on watchOS: viable non-workout paths and CMSensorRecorder behavior

I'm building a sleep tracker for couples — the headline feature is a notification to your partner the moment you fall asleep (and another when you wake up), detected on the Apple Watch from accelerometer and heart-rate data. The detection has to happen within minutes of onset for the product to make sense.

My setup

  • HKObserverQuery on heart rate with enableBackgroundDelivery(.immediate), re-registered on foreground.
  • WKApplicationRefreshBackgroundTask rescheduled every 15 minutes.
  • CMSensorRecorder.recordAccelerometer(forDuration: 12 * 3600) re-armed on every wake.
  • A van Hees-style stillness classifier reading the last ~35 minutes of the buffer, with heart rate as a soft confirmer.
  • HealthKit and Motion & Fitness authorized on both iPhone and watch.
  • The observer's completionHandler() is called on every branch and the handler stays well under the 15-second watchdog.
  • No HKWorkoutSession as my app is not a workout.

Questions

  • Is CMSensorRecorder paused or deprioritized while the Apple Watch's automatic sleep detection has classified the user as asleep?

    On a worn watch with the recorder armed for 12 hours, accelerometerData(from:to:) over a 35-minute window inside the auto-detected sleep period returns zero samples. The exact same call an hour later, once the watch has decided the user is awake, returns roughly ten thousand samples for an equivalent window. The user never activated Sleep Focus or Theater Mode — the only sleep-related state at play is the watch's own automatic detection, the same one that writes Core / REM / Deep stages into Apple Health. Is this documented power management I missed, or is it unexpected? Happy to file Feedback with a sysdiagnose during the window if you confirm it shouldn't behave this way.

  • Is there a sanctioned non-workout path on current watchOS for detecting sleep onset within a few minutes of it happening?

    A full night recently produced a five-hour stretch with zero observer callbacks and zero background-refresh deliveries between bedtime and wake. The historical guidance to third-party sleep apps has been to reconstruct nights post-hoc from sleepAnalysis samples rather than attempt live detection. Is that still the recommendation today, or is there an API I've missed that would give an onset-focused app tighter wakes around bedtime?

  • What is the current App Store review stance on HKWorkoutSession for sleep tracking?

    Would an app that auto-starts a .other / indoor workout only when its own classifier detects pre-sleep signals at the user's typical bedtime, ends the session as soon as onset is confirmed, never starts one outside that gated condition, and explicitly discloses "sleep tracking via workout session" in the App Store metadata — be an acceptable pattern, or grounds for rejection regardless of disclosure?

Is CMSensorRecorder paused or deprioritized while the Apple Watch's automatic sleep detection has classified the user as asleep?

I don't think this is documented, and would like to suggest that you file a feedback report to see what the Core Motion folks have to say – If you do so, please share your report ID here.

It won't be a surprise to me if the behavior is as-designed though. In general, watchOS lowers the sampling rate of it sensors when it determines appropriate.

I am also curions how you did the test, btw. When you observed that CMSensorRecorder was paused, was the watch in the frontmost mode (assuming that you didn't have an active workout session)? If yes, the behavior will be pretty similar to what Michaellee524 concluded in this thread.

Is there a sanctioned non-workout path on current watchOS for detecting sleep onset within a few minutes of it happening?

There isn't. HealthKit does sleep analysis some time after the sleep events happening. There is no guarantee that the sleep analysis samples are written to the Health store "a few minutes" after a sleep stage.

What is the current App Store review stance on HKWorkoutSession for sleep tracking?

I can't speak for App Review, and so would suggest that you contact the team (and share the answer you get here, if you don't mind). To me, using a workout session for sleep tracking is most likely not appropriate.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Sleep onset detection on watchOS: viable non-workout paths and CMSensorRecorder behavior
 
 
Q