When saving a workout to the iOS health store, without any Apple Watch, how should an app calculate totalEnergyBurned?
The Apple uses a hard coded value for totalEnergyBurned, but says a real-world app would calculate this values from sensor data.
HKQuantity *energyBurned = [HKQuantity quantityWithUnit:[HKUnit kilocalorieUnit] doubleValue:425.0];
HKQuantity *distance = [HKQuantity quantityWithUnit:[HKUnit mileUnit] doubleValue:3.2];
HKWorkout *run = [HKWorkout workoutWithActivityType:HKWorkoutActivityTypeRunning
startDate:start
endDate:end
duration:0
totalEnergyBurned:energyBurned
totalDistance:distance
metadata:nil];
[self.healthStore saveObject:run withCompletion:^(BOOL success, NSError *error) {
}];
Thank you
from On iOS, without an Apple Watch, how to collect totalEnergyBurned for a workout?
No comments:
Post a Comment