简体   繁体   English

watchOS:如何在没有心率传感器的情况下使用 HKWorkoutSession

[英]watchOS: How to use HKWorkoutSession without heart rate sensor

I am working on a fitness app where for now I don't want to gain any data through HealthKit.我正在开发一个健身应用程序,目前我不想通过 HealthKit 获取任何数据。 Actually, keeping my app in the background via HKWorkoutSession was the only thing which forced me to use HealtKit for now.实际上,通过 HKWorkoutSession 将我的应用程序保持在后台是目前唯一迫使我使用 HealtKit 的事情。

The problem which I have is that heart rate sensor is running when I stop a workout for ~30sec and sometimes he doesn't want to turn off even after this time.我遇到的问题是当我停止锻炼约 30 秒时心率传感器正在运行,有时即使在此之后他也不想关闭。 I noticed that for example, Strava app has an active workout session when running and he doesn't turn on heart LEDs when it's active, paused or stopped which is a behavior which I would like to achieve as well but after many tries with different HKWorkoutConfiguration I couldn't.我注意到,例如,Strava 应用程序在跑步时有一个积极的锻炼 session,当它处于活动状态、暂停或停止时,他没有打开心脏 LED,这是我也想实现的行为,但经过多次尝试不同的 HKWorkoutConfiguration我不能。

For example:例如:

    let workoutConfiguration = HKWorkoutConfiguration()
    workoutConfiguration.activityType = .running
    workoutConfiguration.locationType = .unknown

I double checked that I don't reuse previous session or the don't have active session.我仔细检查了我没有重复使用以前的 session 或没有活动的 session。

For above configuration, the heart rate LEDs are disabled when workout session is active but when I stop it, they glow and usually go out after 30 seconds (except the cases when they don't want to turn off and I don't have any steps to reproduce, for me it looks totally randomly)对于上述配置,当锻炼 session 处于活动状态时,心率 LED 被禁用,但是当我停止它时,它们会发光并且通常 go 在 30 秒后熄灭(除了他们不想关闭而我没有任何重现的步骤,对我来说它看起来完全随机)

Did anyone use HKWorkoutConfiguration with totally disabled heart rate or faced some issues when the heart rate sensor didn't want to turn off?是否有人使用 HKWorkoutConfiguration 完全禁用心率或在心率传感器不想关闭时遇到一些问题?

Apple Watch automatically performs a heart rate scan at the end of the workout, and periodically every 10-12 minutes while you're wearing the watch (there might be more variance possibly related to movement). Apple Watch 会在锻炼结束时自动执行心率扫描,并在您佩戴手表时每 10-12 分钟定期执行一次(可能与运动有关的差异更大)。 I wouldn't worry about it too much, but if you are concerned that your app is causing the heart rate monitor to activate just check the watch face for the workout in progress icon.我不会太担心,但如果您担心您的应用程序会导致心率监测器激活,只需检查表盘上的“正在进行的锻炼”图标即可。 If it's there then perhaps your app has not ended the workout session correctly.如果它在那里,那么您的应用程序可能没有正确结束锻炼 session。

From the document :文件

The session finetunes Apple Watch's sensors for the specified activity. session 针对指定活动微调 Apple Watch 的传感器。 All workout sessions generate high-frequency heart rate samples;所有锻炼课程都会生成高频心率样本; however, an outdoor cycling activity generates accurate location data, while an indoor cycling activity does not.但是,户外骑行活动会生成准确的位置数据,而室内骑行活动则不会。

All workout sessions generate high-frequency heart rate samples所有锻炼课程都会生成高频心率样本

We can't disable HR sensor because it is a key factor to identify the workout's calories burned.我们不能禁用 HR 传感器,因为它是识别锻炼消耗的卡路里的关键因素。 System will control this sensor when it can run or stop.当它可以运行或停止时,系统将控制这个传感器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HKWorkoutSession:在watchOS 2中关闭屏幕时未获得心率 - HKWorkoutSession: Not getting Heart Rate when screen is turned off in watchOS 2 WatchOS2心率 - WatchOS2 Heart Rate WatchOS 4没有收到心率样本? - WatchOS 4 not receiving heart rate samples? 当watchOS应用程序使用HKWorkoutSession在后台运行时如何使WCSession可访问 - How to make WCSession reachable when the watchOS app is running in background with HKWorkoutSession microsoft band 如何从自定义磁贴读取心率或一些传感器数据并与移动应用程序通信? - microsoft band How to read heart rate or some sensor data from a custom tile and communicate with mobile app? 如何从HR(心率)获得HRV(心率变异性) - How to get HRV (Heart Rate Variability) from HR (Heart Rate) 是否可以创建一个应用程序来读取 Apple Watch 的心率传感器? - Is it possible to create an app to read the heart rate sensor of an Apple watch? 在Apple Watch中访问心率传感器-HealthKit不返回该值 - Accessing heart rate sensor in Apple Watch - HealthKit does not return the value 如何将一组HKQuantitySamples(心率)保存到锻炼中 - How to save an array of HKQuantitySamples (heart rate) to a workout 如何在iOS sdk中不使用任何仪器来检测心率? - How to detect heart pulse rate without using any instrument in iOS sdk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM