HealthKit not saving metadata for sexual activity sample
| Originator: | thedov | ||
| Number: | rdar://23280251 | Date Originated: | 27-Oct-2015 02:49 PM |
| Status: | Closed | Resolved: | Duplicate of 22546920 |
| Product: | iOS SDK | Product Version: | iOS 9.1, Xcode 7.1 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
On device (via TestFlight) but not in the Simulator, specifying a value for ProtectionUsed is not having an effect on the data entered into HealthKit
Steps to Reproduce:
Make a HealthKit app, using the Swift code below to save a sample:
public func writeData(callback: (success: Bool) -> Void) {
guard let sexualActivityIdentifier = HKCategoryType.categoryTypeForIdentifier(HKCategoryTypeIdentifierSexualActivity) else {
callback(success: false)
return
}
let metadata: [String: AnyObject]? = [HKMetadataKeySexualActivityProtectionUsed: true]
let sample = HKCategorySample(type: sexualActivityIdentifier,
value: HKCategoryValue.NotApplicable.rawValue,
startDate: NSDate(),
endDate: NSDate(),
metadata: metadata)
let store = HKHealthStore()
store.saveObject(sample) { (success, error) -> Void in
callback(success: success)
}
}
Expected Results:
The data point in Health shows “Protection used”
Actual Results:
The data point in Health shows “––” on device (with app installed using TestFlight), but “Protection used” in the simulator
Regression:
This worked correctly on a data point entered on 10/6, but stopped working beginning with 10/14. I’m not sure if there was an iOS 9 point release update somewhere in there that may have affected it.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!