我在我的应用程序中使用 HealthKit。我从用户那里获得了访问 HealthKit 数据的许可。授权后,如果我检查特定 HealthKit 对象类型的授权状态,它总是返回访问被拒绝。(1 是枚举整数值)。
这是我的代码
// Steps
if ([self.healthStore authorizationStatusForType:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]] == HKAuthorizationStatusSharingAuthorized) {
[self accessStepsFrom:fromDate to:toDate];
}
//Sleep
if ([self.healthStore authorizationStatusForType:[HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSleepAnalysis]] == HKAuthorizationStatusSharingAuthorized) {
[self accessSleepFrom:fromDate to:toDate];
}
//DOB
if ([self.healthStore authorizationStatusForType:[HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth]] == HKAuthorizationStatusSharingAuthorized) {
[self accessDOB];
}
该方法[self.healthStore authorizationStatusForType:[HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth]]
总是抛出我1
。需要帮助吗?