Having a tough time here figuring out HealthKit data types. I’m building a fitness app and wanted to tap into traditional strength training. Found a guide that had DistanceCycling in there. Tried following the guides over on devdactic and when I swapped it out, it crashed.
saveWorkout() {
let woDuration = this.item.time * 60;
console.log(woDuration);
let workout = {
'activityType': 'HKWorkoutActivityTypeTraditionalStrengthTraining',
'quantityType': 'HKQuantityTypeIdentifierActiveEnergyBurned',
'startDate': new Date(), // now
'endDate': null, // not needed when using duration
'duration': woDuration, //in seconds
'energy': this.hkCals, //
'energyUnit': 'kcal', // J|cal|kcal
// 'distance': 5, // optional
// 'distanceUnit': 'km'
}
this.healthKit.saveWorkout(workout).then(res => {
this.loadHealthData();
})
}
Here’s the error from xcode:
Terminating app due to uncaught exception ‘_HKObjectValidationFailureException’, reason: 'HKQuantitySample (2018-09-21 21:45:14 -0400 - 2018-09-21 22:45:14 -0400) requires unit of type Energy. Incompatible unit: (null)'
anyone have any experience with implementing HealthKit?