gpt4 book ai didi

ios - HKWorkoutSession : Not getting Heart Rate when screen is turned off in watchOS 2

转载 作者:可可西里 更新时间:2023-11-01 04:34:11 29 4
gpt4 key购买 nike

我使用的是 iOS 9 beta 4 和 watchOS 2 beta 4。

当 watch 屏幕变黑(锁定)时,我似乎无法获取任何心率数据。我会接到 applicationWillResignActive 的电话,然后心率数据就停止了。

当屏幕锁定时,传感器似乎也在一段时间后停用(不再是绿色)。

还有其他人看到这种行为吗?如果其他人在 watch 屏幕锁定时获取心率数据,我可以发布用于启动 WorkoutSession 的代码。

最佳答案

从 watchOS 3.0 开始,您可以将带有 workout-processing 值的 WKBackgroundModes 条目添加到扩展程序的 Info.plist 中。

来自docs :

Running in the Background Workout sessions can run in the background. Background running grants an app the following abilities:

The app continues to run throughout the entire workout session, even when the user lowers their wrist or interacts with a different app. When the user raises their wrist, the app reappears, letting the user quickly and easily check their current progress and performance.

The app can continue to access data from Apple Watch’s sensors in the background, letting you keep the app up to date at all times. For example, a running app can continue to track the user’s heart rate, ensuring that the most recent heart rate data is displayed whenever the user raises their wrist.

关于ios - HKWorkoutSession : Not getting Heart Rate when screen is turned off in watchOS 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31830686/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com