health-kit

Get total step count for every date in HealthKit

拥有回忆 提交于 2019-11-26 14:05:39
问题 What's the best way to get a total step count for every day recorded in HealthKit . With HKSampleQuery's method initWithSampleType (see below) I can set a start and end date for the query using NSPredicate , but the method returns an array with many HKQuantitySamples per day. - (instancetype)initWithSampleType:(HKSampleType *)sampleType predicate:(NSPredicate *)predicate limit:(NSUInteger)limit sortDescriptors:(NSArray *)sortDescriptors resultsHandler:(void (^)(HKSampleQuery *query, NSArray

How to force a HKQuery to load the most recent steps counts?

烈酒焚心 提交于 2019-11-26 11:34:11
问题 Currently I\'m trying to use HKStatisticsQuery to get the steps count between a certain time interval. I\'m doing test by shaking the phone myself. However, it seems that the result I get is not the most recent one, unless: I open the Health.app , keep it running in background, and do the test again in my app; I open the UP app , keep it running in background, and do the test again in my app. And if I force-quit the Health.app or UP app , my app will not be able to get the most recent data