How can I gain permission in HealthKit for writing workout routes?

Viewed 597

I'm trying to add map data to my saved runs and bike rides for an Apple Watch app. I'm using CLLocationManager and HKWorkoutRouteBuilder.

Apple seems to have a pretty decent guide on building workout routes here. However, I'm struggling with the sentence in the documentation that says: "Specifically for route data, you must request permission to read and share both HKWorkout and HKWorkoutRoute samples."

Below are my app's current permissions. I know I still need "Workout Routes" to show up as an option, but am struggling to do so. On top of that, I'm not exactly sure if there are other permissions that I would need to obtain as well. enter image description here

Thank you so much for your help!! -David

1 Answers

Whelp... this seems to answer my question!

let sampleTypes: Set<HKSampleType> = [
    HKSampleType.quantityType(forIdentifier: .heartRate)!,
    HKSampleType.quantityType(forIdentifier: .activeEnergyBurned)!,
    HKSampleType.quantityType(forIdentifier: .distanceWalkingRunning)!,
    HKSampleType.quantityType(forIdentifier: .distanceCycling)!,
    HKSeriesType.workoutType(),
    HKSeriesType.workoutRoute(),
]

Just had to add the last two lines to the array of sample types. I hope this helps at least one other person!

Related