HKWorkoutSession:在 watchOS 2 中关闭屏幕时无法获得心率 [英] HKWorkoutSession: Not getting Heart Rate when screen is turned off in watchOS 2

查看:17
本文介绍了HKWorkoutSession:在 watchOS 2 中关闭屏幕时无法获得心率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using iOS 9 beta 4 and watchOS 2 beta 4.

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

I can't seem to get any heart rate data when the watch screen turns black (locks). I will get a call to applicationWillResignActive and then the heart rate data just stops.

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

It seems that the sensor is deactivating after some time as well (not green anymore), when the screen locks.

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

Anyone else seeing this behavior? I can post my code for initing the WorkoutSession if anyone else getting heart rate data when the screen on the watch is locked.

推荐答案

从 watchOS 3.0 开始,您可以将带有 workout-processing 值的 WKBackgroundModes 条目添加到扩展的信息.plist.

Starting in watchOS 3.0 you can add the WKBackgroundModes entry with the workout-processingvalue to the extension's Info.plist.

来自文档:

在后台运行 锻炼会话可以在后台运行.后台运行授予应用以下能力:

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.

该应用程序可以继续访问来自 Apple Watch 传感器的数据后台,让您始终保持应用程序最新.为了例如,正在运行的应用程序可以继续跟踪用户的心率,确保在任何时候都显示最新的心率数据用户抬起手腕.

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.

这篇关于HKWorkoutSession:在 watchOS 2 中关闭屏幕时无法获得心率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆