且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS近乎实时地从Apple Watch获得心率

更新时间:2023-12-03 17:32:58

更新

正如@BootMaker所注意到的,Apple在 WatchOS 3 中为 HKWorkout 应用程序提供了后台模式,因此它现在正在运行。您必须运行 HKWorkoutSession ,即使应用程序处于后台(观看黑屏),这也会实时保持您的实时交付

As noticed by @BootMaker, Apple made background mode available for HKWorkout apps in WatchOS 3, so it's working now. You have to run a HKWorkoutSession and this will keep your heartrate delivery in real time even when the app is in the background (dark screen on watch)

当手表应用程序打开时,最近

The closest you are going to be is while the watch app is open.

为什么我要陈述这个?


  1. 有两个HealthKit的数据库(一个在iPhone上,另一个在Apple Watch )。当他们同步是任意的并且仅由操作系统决定时

  1. There are two HealthKit's Database (one at the iPhone and another at the Apple Watch). When they sync is arbitrary and decided only by the O.S.

您最接近 实时 当您有任何密码锁定 iPhone Apple Watch 中的屏幕时。
无论哪种方式,都不能保证每次将新措施添加到 Apple Watch的HealthKit

The closest you are going to be to real time is when you don't have any password locking your screen in iPhone or Apple Watch. Either way, there's no guarantee that the sync will happen every time a new measure is added to Apple Watch's HealthKit

强迫心率传感器实时工作的唯一方法是通过锻炼观察者,同时 Apple Watch应用位于 FOREGROUND

The only way to force the Heart rate sensor into working in real time is via workouts or observer while your Apple Watch app is in FOREGROUND.

Apple Watch应用程序的后台投放

Background delivery is NOT available for Apple Watch apps.

观看操作系统2 请求传感器每10分钟自动测量一次(在后台)。

Watch OS 2 request the sensor to measure automatically (in background) every 10 minutes minimum.




没有其他解决方法,如果您需要实时如果用户不使用您的应用,您需要使用专业的可穿戴设备

There's no other workaround, if you need real time for longer periods, or while the user is not using your app, you will need to use an specialized wearable.