This is a sample application that communicates with a heart rate monitor via CoreBlueTooth and pushes heart rate information to HealthKit. It doesn't required a connection to the heart rate monitor, it will retreive heart rate information from HealthKit to display if HK is paired with your heart rate monitor.
I wrote this app to learn Swift and provide examples for others as well as myself for various Swift language constructs. Of course, I wanted to learn HealthKit as well.
In this app you will find:
-
Many examples of closures. For one closure, in ViewController.swift, I provided 7 different closure solutions.
-
Use of optionals - normal and implicitly unwrapped
-
Use of constants and properties
-
Outlets and actions
-
Custom delegate
-
Requesting permissions from HealthKit
-
Use of HealthKit to store and retreive heart rate data
To run this app:
-
Create your own bundle id
-
Create an app id with the HealthKit entitlement selected
-
You'll need a heart rate monitor - I tested this with the 60Beat heart monitor