防止 Apple Watch 关闭屏幕

Prevent Apple Watch from turning off the screen

我正在为 Apple Watch 编写一个扩展程序,旨在引导用户完成一系列步骤。我没有手表来测试扩展程序,但我需要确保在完成所有步骤之前,屏幕会一直亮着。

有谁能告诉我 Apple Watch 显示屏何时关闭,或者是否有任何方法可以防止显示屏关闭(类似于 iOS 中 UIApplication 的 idleTimerDisabled)?

目前无法以编程方式阻止显示被关闭。否则,我们可以推测,只要用户与您的应用进行交互,屏幕就会一直亮着。最坏的情况是,当应用程序暂停时您将收到一个 didDeactivate 并在用户将其唤醒以继续时收到一个 willActivate (假设 Watch 应用程序未在其间终止)。

从 watchOS 4 开始,您可以使用此布尔值来保持显示,这将在转动手臂时旋转 UI。

https://developer.apple.com/documentation/watchkit/wkextension/2868464-isautorotating

考虑 HKWorkout

it ensures that your app appears whenever the user checks their watch

https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings