在 iOS 上,没有 Apple Watch,如何收集 totalEnergyBurned 进行锻炼?



在没有任何 Apple Watch 的情况下将体能训练保存到 iOS 健康商店时,应用应该如何计算总能量燃烧?

Apple的示例应用程序使用totalEnergyBurned的硬编码值,但表示实际应用程序将根据传感器数据计算此值。

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) {
}];

谢谢

苹果不会给你开箱即用的方法,除非你有Apple Watch。

像 Strava 和 Nike Run 这样的应用程序根据以下因素计算燃烧的卡路里:

  • 体重
  • 运行距离
  • 运行持续时间

你可以在谷歌上寻找公式,甚至可以在Stack Exchange网络上的其他地方寻找公式:https://fitness.stackexchange.com/questions/15608/energy-expenditure-calories-burned-equation-for-running 这些公式反过来又链接到网络上的优质资源。

相关内容

  • 没有找到相关文章

最新更新