Skip to content

Commit

Permalink
Merge pull request #919 from ikoamu/fix/write-blood-pressure
Browse files Browse the repository at this point in the history
[Health] Add support for saving blood pressure as a correlation(ios)
  • Loading branch information
bardram authored Apr 3, 2024
2 parents d96cf6a + f40f30a commit f6326cb
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit f6326cb

Please sign in to comment.