0

How to read heart rate directly from Apple watch sensor use a custom app (not indirect access via HealthKit)?

All available documents suggests using HKWorkoutSession, but without any information as to how the sensor value can be retrieved. The example provided in the official link below takes in constant values without giving any details how to use sensor values.

https://developer.apple.com/documentation/healthkit/hkworkout

Any information would be much appreciated

rmaddy
  • 314,917
  • 42
  • 532
  • 579
codeheadache
  • 134
  • 1
  • 15

1 Answers1

0

Create an HKWorkoutSession to get the heart rate sensor going, then every time you read a new heart rate on the watch send it to your phone with WCSession.default.sendMessage()

Myk
  • 979
  • 6
  • 16
  • Perfect. HKWorkoutSession works well. However, now whenever I am sending the HeartRate to my iphone using WCSession. I do not get any data on iOS. I am not sure how to debug the iOS side while running the iWatch on simulator. – codeheadache Apr 15 '19 at 11:44
  • If you just make sure the watch simulator and matching phone simulator are up, just switch scheme to the phone and run. This way you'll be able to debug the phone (but not the watch). I don't believe you can debug them both at the same time though. – Myk Apr 15 '19 at 23:35
  • Make sure your iOS code for receiving messages is being called. – Myk Apr 15 '19 at 23:36