HealthKit: Reading HKCorrelationType is not allowed

When I try to initialize HealthKit with sample type HKCorrelation, the application crashes with "Authorization to read the following types: HKCorrelationTypeIdentifierBloodPressure".

I successfully read from different types of amount and types of sleep categories.

The code doesn't touch, but I'm calling

[healthStore requestAuthorizationToShareTypes:writeDataTypes
                                    readTypes:readDataTypes
                                   completion:^(BOOL success, NSError *error) {
... 
}

      

where readDataTypes is an NSSet containing the set of sample types I'm looking for to read. One of them is HKCorrelationTypeIdentifierBloodPressure.

When I remove the blood pressure key from the kit, it works fine.

The set also includes the HKQuantityTypeIdentifierBloodPressureSystolic and HKQuantityTypeIdentifierBloodPressureDiastolic query types.

Does Apple want us to read the combined data type?

+3


source to share


1 answer


I had success asking to resolve the individual elements of the blood pressure correlation:

HKQuantityType *bpSystolicType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBloodPressureSystolic];
HKQuantityType *bpDiastolicType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBloodPressureDiastolic];

      



And then when I want to request samples:

HKSampleType *type = [HKQuantityType correlationTypeForIdentifier:HKCorrelationTypeIdentifierBloodPressure];

      

+8


source







All Articles