Compressed step count data from iOS 11 HealthKit

I'm creating healthcare app. It helps a user to get more physical activities. So, we count user's step counts with Healthkit data and visualize it.

Before iOS 11, it works fine, but iOS 11 Healthkit shows compressed step count data.

If I walked as below time and steps.

09:00 ~ 09:01 -> 102 steps

09:01 ~ 09:02 -> 108 steps

09:02 ~ 09:03 -> 103 steps

09:03 ~ 09:04 -> 106 steps

09:04 ~ 09:05 -> 104 steps

09:05 ~ 09:06 -> 107 steps


Until iOS 10 version, Healthkit shows steps counts as I walked.

But in iOS 11, it seems that Healthkit calculates step count average. Like below


09:00 ~ 09:01 -> 105 steps

09:01 ~ 09:02 -> 105 steps

09:02 ~ 09:03 -> 105 steps

09:03 ~ 09:04 -> 105 steps

09:04 ~ 09:05 -> 105 steps

09:05 ~ 09:06 -> 105 steps


This makes inexact information. It would be great, someone can explain why this happens and how can I get exact step count data.

I got this step count with following query codes.


- (void)statisticsCollectionWithStartDate:(NSDate *)startDate
                                  endDate:(NSDate *)endDate
                       intervalComponents:(NSDateComponents *)intervalComponents
                        completionHandler:(void (^)(HKStatisticsCollection * _Nullable, NSError * _Nullable))completionHandler {
    NSCalendar *calendar = NSCalendar.currentCalendar;
    NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate
                                                               endDate:endDate
                                                               options:HKQueryOptionStrictStartDate | HKQueryOptionStrictEndDate];
    HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:[HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]
                                                                           quantitySamplePredicate:predicate
                                                                                           options:HKStatisticsOptionCumulativeSum
                                                                                        anchorDate:[calendar startOfDayForDate:startDate]
                                                                                intervalComponents:intervalComponents];
    query.initialResultsHandler = ^(HKStatisticsCollectionQuery * _Nonnull query, HKStatisticsCollection * _Nullable result, NSError * _Nullable error) {
        if (completionHandler) {
            completionHandler(result, error);
        }
    };
    [self.healthStore executeQuery:query];
}

Are there healthkit changes of collecting data timing for battery life?

Compressed step count data from iOS 11 HealthKit
 
 
Q