Hello. We have a problem with HealthKit.
The HKStatisticsQuery returns an error saying "authorization not determined", even though I have allowed to retrieve the number of steps on the health care screen and with requestAuthorization function.
A part of the source code is shown below.
let type = HKSampleType.quantityType(forIdentifier: .stepCount)!
let datePredicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate)
let statisticsQuery = HKStatisticsQuery(
quantityType: type,
quantitySamplePredicate: datePredicate,
options: .separateBySource
) { (query, data, error) in
if let _error = error {
// We're going through here.
}
}
It does not always reproduce, but rarely does. Reinstalling does not cure it.
The condition for recovery is unknown, but the situation seems to be changing every day of the week. This may be due to the lack of walking data on particular day.
Does anyone know the cause of this?
Thanks.