From 8e8a884c77d8edfded472e73b874c719c2cd078b Mon Sep 17 00:00:00 2001 From: Mo'men amin Date: Thu, 10 Apr 2025 12:48:01 +0200 Subject: [PATCH] Update SwiftHealthPlugin.swift --- packages/health/ios/Classes/SwiftHealthPlugin.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/health/ios/Classes/SwiftHealthPlugin.swift b/packages/health/ios/Classes/SwiftHealthPlugin.swift index ac70dcb78..e1726438b 100644 --- a/packages/health/ios/Classes/SwiftHealthPlugin.swift +++ b/packages/health/ios/Classes/SwiftHealthPlugin.swift @@ -566,12 +566,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