Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HealthKit: Reading HKCorrelationType is not allowed

When I attempt to initialize HealthKit with an HKCorrelation sample type, the app crashes with 'Authorization to read the following types is disallowed: HKCorrelationTypeIdentifierBloodPressure'.

I've successfully read from a variety of quantity types and the sleep category types.

The code is not contiguous 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 am looking to read. One of them is HKCorrelationTypeIdentifierBloodPressure.

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

The set also includes HKQuantityTypeIdentifierBloodPressureSystolic and HKQuantityTypeIdentifierBloodPressureDiastolic sample types.

Does Apple not want us reading the combined data type?

like image 636
Ron Barr Avatar asked Oct 23 '14 00:10

Ron Barr


1 Answers

I've had success with asking for authorization of the individual elements of the blood pressure correlation:

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

And then when I want to query the samples:

HKSampleType *type = [HKQuantityType correlationTypeForIdentifier:HKCorrelationTypeIdentifierBloodPressure];
like image 175
Dan Waylonis Avatar answered Sep 30 '22 08:09

Dan Waylonis