Search code examples
ioshealthkit

How to query health kit for total activity minutes by day?


I am familiar with HKStatisticsCollectionQuery in HealthKit, but I am not clear how to run a query for the total number of minutes of activity in a specified time frame, rather than the total number of some QuantityType units. Is this covered somewhere in the documentation?


Solution

  • Perform an HKStatisticsQuery specifying the HKQuantityTypeIdentifierAppleExerciseTime quantity type to get the total number of exercise minutes for a given time period.