Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Health] Add support for saving blood pressure as a correlation(ios) #919

Merged
5 changes: 4 additions & 1 deletion packages/health/ios/Classes/SwiftHealthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,12 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
type: HKSampleType.quantityType(forIdentifier: .bloodPressureDiastolic)!,
quantity: HKQuantity(unit: HKUnit.millimeterOfMercury(), doubleValue: diastolic),
start: dateFrom, end: dateTo)
let bpCorrelationType = HKCorrelationType.correlationType(forIdentifier: .bloodPressure)!
let bpCorrelation = Set(arrayLiteral: systolic_sample, diastolic_sample)
let blood_pressure_sample = HKCorrelation(type: bpCorrelationType , start: dateFrom, end: dateTo, objects: bpCorrelation)

HKHealthStore().save(
[systolic_sample, diastolic_sample],
[blood_pressure_sample],
withCompletion: { (success, error) in
if let err = error {
print("Error Saving Blood Pressure Sample: \(err.localizedDescription)")
Expand Down
Loading