On Sunday I finally made a small breakthrough with my project. After staring at my WorkoutManager for some time I realized that the reason I could not display the amount of distance a user had travelled was simply because I never asked from that data from HealthKit. In order to read/write data, I created a set of HealthKit data types such as .heartRate, .activeEnergyBurned, etc but did not ask for .distanceWalkingRunning. After including this last data type in my read set I am now able to display the distance a user travels in a session.
I was having some problems with updating values such as step count, supposedly because the update requests to display the live data resides in a switch case. To go around the possibility of never reaching an update value request, I wrote a getStepCount function that gets called in the case for updating a user’s distance travelled and am able to display an accurate-ish step count that correlates to a user’s distance travelled.
Now that I have an idea of how to display and look at data, my next steps are to start getting into the stress side of the project. To start, my goal is to learn how to push notifications to a user based on heart rate. Apple has a series of HKQuantitiyTypeIdentifiers relating to heartRate: lowHeartRate, highHeartRate, irregularHeartRhythmEvent, and restingHeartRate.
I’d like to write a function that gets placed in the active heart rate update case that compares/utilizes these identifiers to see if a user is stressed. Eventually I’d like to pair this analysis with other identifiers that look at bloodPressure and respiratoryRate. Typical health identifiers such as AppleExerciseTime or AppleStandTime may also be nice to utilize as gentle reminders to users to get up and move around in a time period.
Although I’m not quite sure how any of this data looks coming in/what statistics I’ll need to compare live data to, I think this will be a good starting place for giving stress suggestions.