iOS get heart rate from Apple Watch in near real time

前端 未结 2 568
醉梦人生
醉梦人生 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:44

    If anyone still need to get heart rate or other data in real time. Use this solution:

    1. Develop an apple watch app/extention
    2. In watch app, using HKHealthStore, HKWorkoutConfiguration, HKWorkoutSession, HKLiveWorkoutBuilder to create an Workout. After create workout, your watch app will get heart rate in real time.
    3. Using watch kit connection with WCSession to send data to iPhone app.
    4. Enable background mode both in apple watch and iPhone.

    I tested, even app terminated, we can still get heart rate (I used Local notification for posting heart rate data for debugging)

提交回复
热议问题