Detecting user wakeup from Apple WatchOS 27

Does Apple WatchOS 27 support my iOS 27 app being notified when the user wakes up?

Thanks for the post, this is extremely interesting and I'm more interested to know why you want to get that information? Having a direct API where the app will be told the user wake up would be a privacy and security concern, there is no direct, real-time callback that fires the exact second a user opens their eyes.

Are you using the HealthKit? Is your app a sleep monitor app? When the Apple Watch detects that the user has woken up, it finalizes the sleep session and writes the data to HealthKit. Your iOS app can subscribe to these changes in the background. You request to read access to HKCategoryTypeIdentifierSleepAnalysis. You then set up an HKObserverQuery and enable background delivery using enableBackgroundDelivery(for:frequency:withCompletion:). When the Watch writes the new sleep data to HealthKit upon the user waking up, iOS will wake your app in the background, allowing you to process the event.

If the user utilizes the built-in Sleep Focus, your app can monitor when that Focus mode is turned off, which heavily correlates with the user waking up. You can use INFocusStatusCenter to request authorization to read the user's Focus status.

Because Apple strictly limits background execution to preserve battery life and protect user privacy, it is unlikely that your app will be available for that.

Albert  WWDR

Detecting user wakeup from Apple WatchOS 27
 
 
Q