Skip to content

Commit

Permalink
Merge pull request #1104 from bernd70/master
Browse files Browse the repository at this point in the history
[Health] Deleting entries in iOS only selects own entries

To reproduce the issue:
Add data to the iOS Health using the "Add Data" button in example app, and try to delete using the "Delete Data" button. The steps, for example, will always be there and won't be deleted.
  • Loading branch information
iarata authored Jan 3, 2025
2 parents d198e10 + c1ddc2c commit 5a605c5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/health/ios/Classes/SwiftHealthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,15 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {

let dataType = dataTypeLookUp(key: dataTypeKey)

let predicate = HKQuery.predicateForSamples(
let samplePredicate = HKQuery.predicateForSamples(
withStart: dateFrom, end: dateTo, options: .strictStartDate)
let ownerPredicate = HKQuery.predicateForObjects(from: HKSource.default())
let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false)

let deleteQuery = HKSampleQuery(
sampleType: dataType, predicate: predicate, limit: HKObjectQueryNoLimit,
sampleType: dataType,
predicate: NSCompoundPredicate(andPredicateWithSubpredicates: [samplePredicate, ownerPredicate]),
limit: HKObjectQueryNoLimit,
sortDescriptors: [sortDescriptor]
) { [self] x, samplesOrNil, error in

Expand Down

0 comments on commit 5a605c5

Please sign in to comment.