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?
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With