Does anyone know how to access the heart rate sensor available in watchOS 2 in Xcode 7 beta?
-
This question needs improvement. What have you got so far? or are you just looking for a recommendation? – Evan Carslake Jun 13 '15 at 15:29
-
I am looking for a recommendation – Antonis Jun 13 '15 at 15:40
-
Can someone point out the relevant document in apple developers that shows how to access the heart rate sensor on the apple watch? – Antonis Jun 13 '15 at 15:46
-
Googled it for you: https://www.google.com/search?q=programming+WatchOS+2+heart+rate+sensor&oq=programming+WatchOS+2+heart+rate+sensor&gs_l=serp.3...4628.6781.0.8181.13.9.0.1.1.0.341.1174.2-2j2.4.0....0...1c.1.64.serp..9.4.933.x6O9vtxtgL4 – Evan Carslake Jun 13 '15 at 16:16
-
I have source code. Is it appropriate to post on StackOverflow while xcode 7 and watchos 2 are in beta stages? – YichenBman Jun 25 '15 at 05:08
-
please post the source code! – Ing. Ron Jul 31 '15 at 21:56
3 Answers
Apple isn't technically giving developers access to the heart rate sensors in watchOS 2.0. What they are doing is providing direct access to heart rate data recorded by the sensor in HealthKit. See the stack overflow answer to this question for more detail.
Many of software kits for iOS are now available for watchOS, such as HealthKit.
You can use HealthKit (HK) functions and classes in order to calculate burned calories, find heart rate, etc.
You can use HKWorkout
to calculate everything about workouts and access the related variables such as heart rate, just like you did with iOS before.
Read developer documentations from Apple in order to learn about HealthKit. They can be found in developer.apple.com.
Resources
For more details about HKWorkout
, you should check out the HKWorkout Class Reference and the HKWorkoutSession Class Reference from Apple.
Also don't forget to check out this great WWDC15 video.

- 3,470
- 18
- 30
-
1This answers is too vague, would be great to have an example or a link to a example. – Diogo T Apr 09 '16 at 00:21
-
I have edited the question to something more interesting and not vague. I have also added links to class references from Apple and a WWDC15 video. – Seyed Parsa Neshaei Apr 09 '16 at 11:13