Reputation: 6869
I try to get authorization to save samples of type HKCategoryTypeIdentifierAppleStandHour:
var healthKitTypesToRead: Set<HKObjectType> = Set<HKObjectType>()
var healthKitTypesToWrite: Set<HKSampleType> = Set<HKSampleType>()
healthKitTypesToWrite.insert(HKSampleType.categoryTypeForIdentifier(HKCategoryTypeIdentifierAppleStandHour)!)
...
healthStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead) {
(success: Bool, error: NSError?) -> Void in
if let error = error {
dispatch_async(dispatch_get_main_queue(),{
print ("success: \(success), error: \(error.localizedDescription)")
})
}
}
when I'm running this code, I get the exception
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Authorization to share the following types is disallowed:
HKCategoryTypeIdentifierAppleStandHour'
Am I doing something wrong or is Apple really prohibiting writing samples of this type?
Tested with (iOS 9.0 and iOS 9.1) and XCode 7.1
Edit iOS 9.3/watchOS 2.2 adds functionality but not this one
Upvotes: 2
Views: 426
Reputation: 7363
Apps are not permitted to save samples with the HKCategoryTypeIdentifierAppleStandHour
type. Apps may only query for existing stand hours already stored in HealthKit by the Apple Watch.
Upvotes: 3