iOS get heart rate from Apple Watch in near real time

前端 未结 2 536
醉梦人生
醉梦人生 2020-12-08 01:26

I need to make an app that records heart rate data in near real time and send this data to a server as soon as possible.

First I took this approach: Watch os 2.0 bet

2条回答
  •  囚心锁ツ
    2020-12-08 01:46

    UPDATE

    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.

    Why I'm stating this?

    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.

    2. 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

    3. 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.

    4. Background delivery is NOT available for Apple Watch apps.

    5. 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.

提交回复
热议问题