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

标签 ios watchkit apple-watch healthkit watchos-2

我使用的是 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/

相关文章:

swift - 获取 Apple Watch 上的 RSSI

ios - 如何在iOS和watchOS 2之间建立与Lister App类似的共享框架的项目?

ios - NSPredicate 获取带有名称和条件的项目

ios - 未绑定(bind)变量命令 PhaseScriptExecution 失败,退出代码非零

swift - 我们是使用静态通知还是动态通知从服务器获取用户名和头像?

ios - 在背景和屏幕关闭时在 WatchKit 锻炼应用程序中播放音频

ios - 如何从异步方法返回多个结果?

ios - 从线程调用 View Controller 的方法

iOS:Watch Kit 获取当前位置并显示在 map 上

xamarin.forms - 我们可以将 Apple Watch 扩展添加到 xamarin 表单应用程序(跨平台应用程序)吗?