Search code examples
iosiphonewatchkitwatch

Setting up WatchKit for a workout app


I have a workout app that queries HealthKit for a heart rate periodically using a timer. However, it appears the Apple watch does not update the heart rate as frequently as I had hoped.

During the workout, the user should be able to monitor their heart rate to ensure they are not exceeding a maximum and within a target range. With the limitations I've found in getting a more frequent heart rate from the watch, it does not update frequent enough to be useful.

I have found some information on GitHub and here that I need a Watch extension with my app. Here's what I have done so far (which is not much). Added a watch extension to the app which created a WatchKit and WatchKit app to my project. I then made sure the bundle versions on all .plist files are the same.

I know that is not much but if someone could guide me to better resources to figure out how to get the features I'm looking for it would be greatly appreciated.

Thank you in advance.

Kevin


Solution

  • Here is the code you need. Heart rate is updated every 5 seconds when you start a workout. https://github.com/coolioxlr/watchOS-3-heartrate