如何检测 Apple Watch 屏幕截图 event/digital 表冠 + 侧键按下?

How do I detect the Apple Watch screenshot event/digital crown + side button press?

例如,原生锻炼应用程序和 Sportstracker 可以在用户同时按下数字表冠和侧面按钮时暂停锻炼,也就是截屏。

我需要这样的东西,但我在文档或其他任何在线地方都找不到任何相关信息。对于 iOS,有 "notificationUIApplicationUserDidTakeScreenshot",但这在 watchOS 上不起作用。

有人知道怎么做吗?它是公开的还是私有的 API?是我不够好看吗?

我还没有尝试过这个,但是在 HealthKit 文档中进行了一些挖掘,它看起来像:

  1. 你大概有一个 HKWorkoutSession to run your workout anyway, right? And it'll need an HKWorkoutSessionDelegate 处理它的状态变化等等。

  2. 当用户同时按下侧边按钮和 Digital Crown 时,您的代表应该得到一个 workoutSession(_:didGenerate:) callback, with the corresponding even having an event type of pauseOrResumeRequest. (They might or might not also get a screenshot,但这是您无法控制的。)

  3. 您通过在 HKHealthStore 上调用 pause(_:) 来处理用户的暂停请求。