I can able to read distanceWalkingRunning data on most of the devices. But in some devices data is not retrieving.
guard let disType = HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning) else {
fatalError("*** Unable to get the distance ***")
}
let query = HKStatisticsCollectionQuery.init(quantityType: disType,
quantitySamplePredicate: nil,
options: [.cumulativeSum],
anchorDate: anchor,
intervalComponents: interval)
query.initialResultsHandler = {
query, results, error in
results?.enumerateStatistics(from: startDate,
to: Date(), with: { (result, stop) in
let distance = result.sumQuantity()?.doubleValue(for: HKUnit.mile()) ?? 0
})
}
healthStore.execute(query)
}
In the same model same version not working in few device. Please guide me to get data on all devices. Thanks.