@@ -319,6 +319,10 @@ class HealthDataReader {
319319 healthStore. execute ( query)
320320 }
321321
322+ /// Gets single health data by UUID
323+ /// - Parameters:
324+ /// - call: Flutter method call
325+ /// - result: Flutter result callback
322326 func getDataByUUID( call: FlutterMethodCall , result: @escaping FlutterResult ) {
323327
324328 guard let arguments = call. arguments as? NSDictionary ,
@@ -333,9 +337,6 @@ class HealthDataReader {
333337 }
334338
335339 let dataUnitKey = arguments [ " dataUnitKey " ] as? String
336- let recordingMethodsToFilter = ( arguments [ " recordingMethodsToFilter " ] as? [ Int ] ) ?? [ ]
337- let includeManualEntry = !recordingMethodsToFilter. contains ( HealthConstants . RecordingMethod. manual. rawValue)
338-
339340 var unit : HKUnit ?
340341 if let dataUnitKey = dataUnitKey {
341342 unit = unitDict [ dataUnitKey] // Ensure unitDict exists and contains the key
@@ -351,7 +352,7 @@ class HealthDataReader {
351352 }
352353
353354 guard let uuid = UUID ( uuidString: uuidarg) else {
354- result ( false )
355+ result ( nil )
355356 return
356357 }
357358
@@ -360,11 +361,6 @@ class HealthDataReader {
360361 let sourceIdForCharacteristic = " com.apple.Health "
361362 let sourceNameForCharacteristic = " Health "
362363
363- if ( !includeManualEntry) {
364- let manualPredicate = NSPredicate ( format: " metadata.%K != YES " , HKMetadataKeyWasUserEntered)
365- predicate = NSCompoundPredicate ( type: . and, subpredicates: [ predicate, manualPredicate] )
366- }
367-
368364 let query = HKSampleQuery (
369365 sampleType: dataType,
370366 predicate: predicate,
@@ -374,7 +370,6 @@ class HealthDataReader {
374370 [ self ]
375371 x, samplesOrNil, error in
376372
377-
378373 guard error == nil else {
379374 DispatchQueue . main. async {
380375 result ( FlutterError ( code: " HEALTH_ERROR " ,
@@ -386,7 +381,7 @@ class HealthDataReader {
386381
387382 guard let samples = samplesOrNil else {
388383 DispatchQueue . main. async {
389- result ( [ ] )
384+ result ( nil )
390385 }
391386 return
392387 }
@@ -408,7 +403,7 @@ class HealthDataReader {
408403 ]
409404 }
410405 DispatchQueue . main. async {
411- result ( dictionaries)
406+ result ( dictionaries. first )
412407 }
413408 } else if var categorySamples = samples as? [ HKCategorySample ] {
414409 // filter category samples based on dataTypeKey
@@ -454,7 +449,7 @@ class HealthDataReader {
454449 ]
455450 }
456451 DispatchQueue . main. async {
457- result ( categories)
452+ result ( categories. first )
458453 }
459454 } else if let workoutSamples = samples as? [ HKWorkout ] {
460455 let dictionaries = workoutSamples. map { sample -> NSDictionary in
@@ -481,7 +476,7 @@ class HealthDataReader {
481476 }
482477
483478 DispatchQueue . main. async {
484- result ( dictionaries)
479+ result ( dictionaries. first )
485480 }
486481 } else if let audiogramSamples = samples as? [ HKAudiogramSample ] {
487482 let dictionaries = audiogramSamples. map { sample -> NSDictionary in
@@ -507,7 +502,7 @@ class HealthDataReader {
507502 ]
508503 }
509504 DispatchQueue . main. async {
510- result ( dictionaries)
505+ result ( dictionaries. first )
511506 }
512507 } else if let nutritionSamples = samples as? [ HKCorrelation ] {
513508 var foods : [ [ String : Any ? ] ] = [ ]
@@ -543,13 +538,13 @@ class HealthDataReader {
543538 }
544539
545540 DispatchQueue . main. async {
546- result ( foods)
541+ result ( foods. first )
547542 }
548543 } else {
549544 if #available( iOS 14 . 0 , * ) , let ecgSamples = samples as? [ HKElectrocardiogram ] {
550545 let dictionaries = ecgSamples. map ( self . fetchEcgMeasurements)
551546 DispatchQueue . main. async {
552- result ( dictionaries)
547+ result ( dictionaries. first )
553548 }
554549 } else {
555550 DispatchQueue . main. async {
0 commit comments