From dd6a32a5af51ffee1c4b2ef0f3e932bb6ed14914 Mon Sep 17 00:00:00 2001 From: bruce3x Date: Tue, 26 Dec 2023 17:10:13 +0800 Subject: [PATCH 1/6] feat: add `STAND_TIME` data type --- packages/health/README.md | 7 ++++--- packages/health/ios/Classes/SwiftHealthPlugin.swift | 4 +++- packages/health/lib/src/data_types.dart | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/health/README.md b/packages/health/README.md index f3d47d36a..c2b583427 100644 --- a/packages/health/README.md +++ b/packages/health/README.md @@ -23,7 +23,7 @@ Note that for Android, the target phone **needs** to have [Google Fit](https://w ## Data Types | **Data Type** | **Unit** | **iOS** | **Android (Google Fit)** | **Android (Health Connect)** | **Comments** | -| --------------------------- | ----------------------- | ------- | ------------------------ |------------------------------| -------------------------------------- | +|-----------------------------|-------------------------| ------- |--------------------------|------------------------------| -------------------------------------- | | ACTIVE_ENERGY_BURNED | CALORIES | yes | yes | yes | | | BASAL_ENERGY_BURNED | CALORIES | yes | | yes | | | BLOOD_GLUCOSE | MILLIGRAM_PER_DECILITER | yes | yes | yes | | @@ -37,8 +37,8 @@ Note that for Android, the target phone **needs** to have [Google Fit](https://w | HEART_RATE | BEATS_PER_MINUTE | yes | yes | yes | | | HEIGHT | METERS | yes | yes | yes | | | RESTING_HEART_RATE | BEATS_PER_MINUTE | yes | | yes | | -| RESPIRATORY_RATE | RESPIRATIONS_PER_MINUTE | yes | | yes | -| PERIPHERAL_PERFUSION_INDEX | PERCENTAGE | yes | | | +| RESPIRATORY_RATE | RESPIRATIONS_PER_MINUTE | yes | | yes | +| PERIPHERAL_PERFUSION_INDEX | PERCENTAGE | yes | | | | STEPS | COUNT | yes | yes | yes | | | WAIST_CIRCUMFERENCE | METERS | yes | | | | | WALKING_HEART_RATE | BEATS_PER_MINUTE | yes | | | | @@ -71,6 +71,7 @@ Note that for Android, the target phone **needs** to have [Google Fit](https://w | AUDIOGRAM | DECIBEL_HEARING_LEVEL | yes | | | | | ELECTROCARDIOGRAM | VOLT | yes | | | Requires Apple Watch to write the data | | NUTRITION | NO_UNIT | yes | yes | yes | | +| STAND_TIME | MINUTES | yes | | | | ## Setup diff --git a/packages/health/ios/Classes/SwiftHealthPlugin.swift b/packages/health/ios/Classes/SwiftHealthPlugin.swift index 36d560010..89f18882a 100644 --- a/packages/health/ios/Classes/SwiftHealthPlugin.swift +++ b/packages/health/ios/Classes/SwiftHealthPlugin.swift @@ -62,7 +62,8 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { let HEADACHE_SEVERE = "HEADACHE_SEVERE" let ELECTROCARDIOGRAM = "ELECTROCARDIOGRAM" let NUTRITION = "NUTRITION" - + let STAND_TIME = "STAND_TIME" + // Health Unit types // MOLE_UNIT_WITH_MOLAR_MASS, // requires molar mass input - not supported yet // MOLE_UNIT_WITH_PREFIX_MOLAR_MASS, // requires molar mass & prefix input - not supported yet @@ -1052,6 +1053,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { dataTypesDict[WORKOUT] = HKSampleType.workoutType() dataTypesDict[NUTRITION] = HKSampleType.correlationType( forIdentifier: .food)! + dataTypesDict[STAND_TIME] = HKSampleType.quantityType(forIdentifier: .appleStandTime) healthDataTypes = Array(dataTypesDict.values) } diff --git a/packages/health/lib/src/data_types.dart b/packages/health/lib/src/data_types.dart index bca127cd0..1c2372834 100644 --- a/packages/health/lib/src/data_types.dart +++ b/packages/health/lib/src/data_types.dart @@ -49,6 +49,7 @@ enum HealthDataType { HEADACHE_SEVERE, HEADACHE_UNSPECIFIED, NUTRITION, + STAND_TIME, // Heart Rate events (specific to Apple Watch) HIGH_HEART_RATE_EVENT, @@ -114,6 +115,7 @@ const List _dataTypeKeysIOS = [ HealthDataType.HEADACHE_UNSPECIFIED, HealthDataType.ELECTROCARDIOGRAM, HealthDataType.NUTRITION, + HealthDataType.STAND_TIME, ]; /// List of data types available on Android @@ -208,6 +210,7 @@ const Map _dataTypeToUnit = { HealthDataType.ELECTROCARDIOGRAM: HealthDataUnit.VOLT, HealthDataType.NUTRITION: HealthDataUnit.NO_UNIT, + HealthDataType.STAND_TIME: HealthDataUnit.MINUTE, }; const PlatformTypeJsonValue = { From b6978abbba4ab6cf54a94ec34ebc4f8348d6bb50 Mon Sep 17 00:00:00 2001 From: bruce3x Date: Mon, 8 Jan 2024 18:56:52 +0800 Subject: [PATCH 2/6] feat: get data only from watch --- packages/health/ios/Classes/SwiftHealthPlugin.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/health/ios/Classes/SwiftHealthPlugin.swift b/packages/health/ios/Classes/SwiftHealthPlugin.swift index 89f18882a..280e5e3dd 100644 --- a/packages/health/ios/Classes/SwiftHealthPlugin.swift +++ b/packages/health/ios/Classes/SwiftHealthPlugin.swift @@ -582,10 +582,13 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { let predicate = HKQuery.predicateForSamples( withStart: dateFrom, end: dateTo, options: .strictStartDate) + let watchPredicate = HKQuery.predicateForObjects(withDeviceProperty: HKDevicePropertyKeyModel, allowedValues: ["Watch"]) + let combinedPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [predicate, watchPredicate]) + let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false) let query = HKSampleQuery( - sampleType: dataType, predicate: predicate, limit: limit, sortDescriptors: [sortDescriptor] + sampleType: dataType, predicate: combinedPredicate, limit: limit, sortDescriptors: [sortDescriptor] ) { [self] x, samplesOrNil, error in From 23063455a84941b872fb56fd4bf440b85ecd6655 Mon Sep 17 00:00:00 2001 From: ikoamu Date: Sat, 24 Feb 2024 18:13:55 +0900 Subject: [PATCH 3/6] Add support for saving blood pressure as a correlation(ios) --- packages/health/ios/Classes/SwiftHealthPlugin.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/health/ios/Classes/SwiftHealthPlugin.swift b/packages/health/ios/Classes/SwiftHealthPlugin.swift index 36d560010..070968760 100644 --- a/packages/health/ios/Classes/SwiftHealthPlugin.swift +++ b/packages/health/ios/Classes/SwiftHealthPlugin.swift @@ -404,9 +404,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)") From 42f7eef7ceef85adb6e55d6627431c58155b4bd6 Mon Sep 17 00:00:00 2001 From: tm-hirai Date: Thu, 14 Mar 2024 21:46:29 +0900 Subject: [PATCH 4/6] add body water mass to health connect --- packages/health/README.md | 1 + .../cachet/plugins/health/HealthPlugin.kt | 18 ++++++++++++++++++ packages/health/lib/src/data_types.dart | 3 +++ 3 files changed, 22 insertions(+) diff --git a/packages/health/README.md b/packages/health/README.md index 800e245fc..7d6a63ca2 100644 --- a/packages/health/README.md +++ b/packages/health/README.md @@ -33,6 +33,7 @@ Note that for Android, the target phone **needs** to have [Google Fit](https://w | BODY_FAT_PERCENTAGE | PERCENTAGE | yes | yes | yes | | | BODY_MASS_INDEX | NO_UNIT | yes | yes | yes | | | BODY_TEMPERATURE | DEGREE_CELSIUS | yes | yes | yes | | +| BODY_WATER_MASS | KILOGRAMS | | | yes | | | ELECTRODERMAL_ACTIVITY | SIEMENS | yes | | | | | HEART_RATE | BEATS_PER_MINUTE | yes | yes | yes | | | HEIGHT | METERS | yes | yes | yes | | diff --git a/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt b/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt index 424f0afea..77014f78d 100644 --- a/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt +++ b/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt @@ -85,6 +85,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) : private var ACTIVE_ENERGY_BURNED = "ACTIVE_ENERGY_BURNED" private var HEART_RATE = "HEART_RATE" private var BODY_TEMPERATURE = "BODY_TEMPERATURE" + private var BODY_WATER_MASS = "BODY_WATER_MASS" private var BLOOD_PRESSURE_SYSTOLIC = "BLOOD_PRESSURE_SYSTOLIC" private var BLOOD_PRESSURE_DIASTOLIC = "BLOOD_PRESSURE_DIASTOLIC" private var BLOOD_OXYGEN = "BLOOD_OXYGEN" @@ -1940,6 +1941,16 @@ class HealthPlugin(private var channel: MethodChannel? = null) : ), ) + is BodyWaterMassRecord -> return listOf( + mapOf( + "value" to record.mass.inKilograms, + "date_from" to record.time.toEpochMilli(), + "date_to" to record.time.toEpochMilli(), + "source_id" to "", + "source_name" to metadata.dataOrigin.packageName, + ), + ) + is BloodPressureRecord -> return listOf( mapOf( "value" to if (dataType == BLOOD_PRESSURE_DIASTOLIC) record.diastolic.inMillimetersOfMercury else record.systolic.inMillimetersOfMercury, @@ -2122,6 +2133,12 @@ class HealthPlugin(private var channel: MethodChannel? = null) : zoneOffset = null, ) + BODY_WATER_MASS -> BodyWaterMassRecord( + time = Instant.ofEpochMilli(startTime), + mass = Mass.kilograms(value), + zoneOffset = null, + ) + BLOOD_OXYGEN -> OxygenSaturationRecord( time = Instant.ofEpochMilli(startTime), percentage = Percentage(value), @@ -2406,6 +2423,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) : ACTIVE_ENERGY_BURNED to ActiveCaloriesBurnedRecord::class, HEART_RATE to HeartRateRecord::class, BODY_TEMPERATURE to BodyTemperatureRecord::class, + BODY_WATER_MASS to BodyWaterMassRecord::class, BLOOD_PRESSURE_SYSTOLIC to BloodPressureRecord::class, BLOOD_PRESSURE_DIASTOLIC to BloodPressureRecord::class, BLOOD_OXYGEN to OxygenSaturationRecord::class, diff --git a/packages/health/lib/src/data_types.dart b/packages/health/lib/src/data_types.dart index bca127cd0..ffda58380 100644 --- a/packages/health/lib/src/data_types.dart +++ b/packages/health/lib/src/data_types.dart @@ -12,6 +12,7 @@ enum HealthDataType { BODY_FAT_PERCENTAGE, BODY_MASS_INDEX, BODY_TEMPERATURE, + BODY_WATER_MASS, DIETARY_CARBS_CONSUMED, DIETARY_ENERGY_CONSUMED, DIETARY_FATS_CONSUMED, @@ -126,6 +127,7 @@ const List _dataTypeKeysAndroid = [ HealthDataType.BODY_FAT_PERCENTAGE, HealthDataType.BODY_MASS_INDEX, HealthDataType.BODY_TEMPERATURE, + HealthDataType.BODY_WATER_MASS, HealthDataType.HEART_RATE, HealthDataType.HEIGHT, HealthDataType.STEPS, @@ -160,6 +162,7 @@ const Map _dataTypeToUnit = { HealthDataType.BODY_FAT_PERCENTAGE: HealthDataUnit.PERCENT, HealthDataType.BODY_MASS_INDEX: HealthDataUnit.NO_UNIT, HealthDataType.BODY_TEMPERATURE: HealthDataUnit.DEGREE_CELSIUS, + HealthDataType.BODY_WATER_MASS: HealthDataUnit.KILOGRAM, HealthDataType.DIETARY_CARBS_CONSUMED: HealthDataUnit.GRAM, HealthDataType.DIETARY_ENERGY_CONSUMED: HealthDataUnit.KILOCALORIE, HealthDataType.DIETARY_FATS_CONSUMED: HealthDataUnit.GRAM, From 5342c0d0ff2e860db3a63d4d99c4ce975b06d609 Mon Sep 17 00:00:00 2001 From: ikoamu Date: Mon, 1 Apr 2024 00:18:29 +0900 Subject: [PATCH 5/6] resolve conflict --- packages/health/README.md | 376 +++++++++--------- .../ios/Classes/SwiftHealthPlugin.swift | 9 +- packages/health/lib/src/heath_data_types.dart | 3 - 3 files changed, 191 insertions(+), 197 deletions(-) diff --git a/packages/health/README.md b/packages/health/README.md index ec4463048..e37d43a7e 100644 --- a/packages/health/README.md +++ b/packages/health/README.md @@ -191,7 +191,7 @@ Below is a simplified flow of how to use the plugin. ```dart // configure the health plugin before use. Health().configure(useHealthConnectIfAvailable: true); - + // define the types to get var types = [ HealthDataType.STEPS, @@ -281,196 +281,196 @@ points = Health().removeDuplicates(points); The plugin supports the following [`HealthDataType`](https://pub.dev/documentation/health/latest/health/HealthDataType.html). | **Data Type** | **Unit** | **Apple Health** | **Google Fit** | **Google Health Connect** | **Comments** | -| --------------------------- | ----------------------- | ---------------- | -------------- | ------------------------- | -------------------------------------- | -| ACTIVE_ENERGY_BURNED | CALORIES | yes | yes | yes | | -| BASAL_ENERGY_BURNED | CALORIES | yes | | yes | | -| BLOOD_GLUCOSE | MILLIGRAM_PER_DECILITER | yes | yes | yes | | -| BLOOD_OXYGEN | PERCENTAGE | yes | yes | yes | | -| BLOOD_PRESSURE_DIASTOLIC | MILLIMETER_OF_MERCURY | yes | yes | yes | | -| BLOOD_PRESSURE_SYSTOLIC | MILLIMETER_OF_MERCURY | yes | yes | yes | | -| BODY_FAT_PERCENTAGE | PERCENTAGE | yes | yes | yes | | -| BODY_MASS_INDEX | NO_UNIT | yes | yes | yes | | -| BODY_TEMPERATURE | DEGREE_CELSIUS | yes | yes | yes | | -| BODY_WATER_MASS | KILOGRAMS | | | yes | | -| ELECTRODERMAL_ACTIVITY | SIEMENS | yes | | | | -| HEART_RATE | BEATS_PER_MINUTE | yes | yes | yes | | -| HEIGHT | METERS | yes | yes | yes | | -| RESTING_HEART_RATE | BEATS_PER_MINUTE | yes | | yes | | -| RESPIRATORY_RATE | RESPIRATIONS_PER_MINUTE | yes | | yes | | -| PERIPHERAL_PERFUSION_INDEX | PERCENTAGE | yes | | | | -| STEPS | COUNT | yes | yes | yes | | -| WAIST_CIRCUMFERENCE | METERS | yes | | | | -| WALKING_HEART_RATE | BEATS_PER_MINUTE | yes | | | | -| WEIGHT | KILOGRAMS | yes | yes | yes | | -| DISTANCE_WALKING_RUNNING | METERS | yes | | | | -| FLIGHTS_CLIMBED | COUNT | yes | | yes | | -| MOVE_MINUTES | MINUTES | | yes | | | -| DISTANCE_DELTA | METERS | | yes | yes | | -| MINDFULNESS | MINUTES | yes | | | | -| SLEEP_IN_BED | MINUTES | yes | | | | -| SLEEP_ASLEEP | MINUTES | yes | | yes | | -| SLEEP_AWAKE | MINUTES | yes | | yes | | -| SLEEP_DEEP | MINUTES | yes | | yes | | -| SLEEP_LIGHT | MINUTES | | | yes | | -| SLEEP_REM | MINUTES | yes | | yes | | -| SLEEP_OUT_OF_BED | MINUTES | | | yes | | -| SLEEP_SESSION | MINUTES | | | yes | | -| WATER | LITER | yes | yes | yes | | -| EXERCISE_TIME | MINUTES | yes | | | | -| WORKOUT | NO_UNIT | yes | yes | yes | See table below | -| HIGH_HEART_RATE_EVENT | NO_UNIT | yes | | | Requires Apple Watch to write the data | -| LOW_HEART_RATE_EVENT | NO_UNIT | yes | | | Requires Apple Watch to write the data | -| IRREGULAR_HEART_RATE_EVENT | NO_UNIT | yes | | | Requires Apple Watch to write the data | -| HEART_RATE_VARIABILITY_SDNN | MILLISECONDS | yes | | | Requires Apple Watch to write the data | -| HEADACHE_NOT_PRESENT | MINUTES | yes | | | | -| HEADACHE_MILD | MINUTES | yes | | | | -| HEADACHE_MODERATE | MINUTES | yes | | | | -| HEADACHE_SEVERE | MINUTES | yes | | | | -| HEADACHE_UNSPECIFIED | MINUTES | yes | | | | -| AUDIOGRAM | DECIBEL_HEARING_LEVEL | yes | | | | -| ELECTROCARDIOGRAM | VOLT | yes | | | Requires Apple Watch to write the data | -| NUTRITION | NO_UNIT | yes | yes | yes | | +| --------------------------- | ----------------------- | ------- | ----------------------- |---------------------------| -------------------------------------- | +| ACTIVE_ENERGY_BURNED | CALORIES | yes | yes | yes | | +| BASAL_ENERGY_BURNED | CALORIES | yes | | yes | | +| BLOOD_GLUCOSE | MILLIGRAM_PER_DECILITER | yes | yes | yes | | +| BLOOD_OXYGEN | PERCENTAGE | yes | yes | yes | | +| BLOOD_PRESSURE_DIASTOLIC | MILLIMETER_OF_MERCURY | yes | yes | yes | | +| BLOOD_PRESSURE_SYSTOLIC | MILLIMETER_OF_MERCURY | yes | yes | yes | | +| BODY_FAT_PERCENTAGE | PERCENTAGE | yes | yes | yes | | +| BODY_MASS_INDEX | NO_UNIT | yes | yes | yes | | +| BODY_TEMPERATURE | DEGREE_CELSIUS | yes | yes | yes | | +| BODY_WATER_MASS | KILOGRAMS | | | yes | | +| ELECTRODERMAL_ACTIVITY | SIEMENS | yes | | | | +| HEART_RATE | BEATS_PER_MINUTE | yes | yes | yes | | +| HEIGHT | METERS | yes | yes | yes | | +| RESTING_HEART_RATE | BEATS_PER_MINUTE | yes | | yes | | +| RESPIRATORY_RATE | RESPIRATIONS_PER_MINUTE | yes | | yes | | +| PERIPHERAL_PERFUSION_INDEX | PERCENTAGE | yes | | | | +| STEPS | COUNT | yes | yes | yes | | +| WAIST_CIRCUMFERENCE | METERS | yes | | | | +| WALKING_HEART_RATE | BEATS_PER_MINUTE | yes | | | | +| WEIGHT | KILOGRAMS | yes | yes | yes | | +| DISTANCE_WALKING_RUNNING | METERS | yes | | | | +| FLIGHTS_CLIMBED | COUNT | yes | | yes | | +| MOVE_MINUTES | MINUTES | | yes | | | +| DISTANCE_DELTA | METERS | | yes | yes | | +| MINDFULNESS | MINUTES | yes | | | | +| SLEEP_IN_BED | MINUTES | yes | | | | +| SLEEP_ASLEEP | MINUTES | yes | | yes | | +| SLEEP_AWAKE | MINUTES | yes | | yes | | +| SLEEP_DEEP | MINUTES | yes | | yes | | +| SLEEP_LIGHT | MINUTES | | | yes | | +| SLEEP_REM | MINUTES | yes | | yes | | +| SLEEP_OUT_OF_BED | MINUTES | | | yes | | +| SLEEP_SESSION | MINUTES | | | yes | | +| WATER | LITER | yes | yes | yes | | +| EXERCISE_TIME | MINUTES | yes | | | | +| WORKOUT | NO_UNIT | yes | yes | yes | See table below | +| HIGH_HEART_RATE_EVENT | NO_UNIT | yes | | | Requires Apple Watch to write the data | +| LOW_HEART_RATE_EVENT | NO_UNIT | yes | | | Requires Apple Watch to write the data | +| IRREGULAR_HEART_RATE_EVENT | NO_UNIT | yes | | | Requires Apple Watch to write the data | +| HEART_RATE_VARIABILITY_SDNN | MILLISECONDS | yes | | | Requires Apple Watch to write the data | +| HEADACHE_NOT_PRESENT | MINUTES | yes | | | | +| HEADACHE_MILD | MINUTES | yes | | | | +| HEADACHE_MODERATE | MINUTES | yes | | | | +| HEADACHE_SEVERE | MINUTES | yes | | | | +| HEADACHE_UNSPECIFIED | MINUTES | yes | | | | +| AUDIOGRAM | DECIBEL_HEARING_LEVEL | yes | | | | +| ELECTROCARDIOGRAM | VOLT | yes | | | Requires Apple Watch to write the data | +| NUTRITION | NO_UNIT | yes | yes | yes | | ## Workout Types The plugin supports the following [`HealthWorkoutActivityType`](https://pub.dev/documentation/health/latest/health/HealthWorkoutActivityType.html). | **Workout Type** | **Apple Health** | **Google Fit** | **Google Health Connect** | **Comments** | -| -------------------------------- | ---------------- | -------------- | ------------------------- | ----------------------------------------------------------------- | -| ARCHERY | yes | yes | | | -| BADMINTON | yes | yes | yes | | -| BASEBALL | yes | yes | yes | | -| BASKETBALL | yes | yes | yes | | -| BIKING | yes | yes | yes | on iOS this is CYCLING, but name changed here to fit with Android | -| BOXING | yes | yes | yes | | -| CRICKET | yes | yes | yes | | -| CURLING | yes | yes | | | -| ELLIPTICAL | yes | yes | yes | | -| FENCING | yes | yes | yes | | -| AMERICAN_FOOTBALL | yes | yes | yes | | -| AUSTRALIAN_FOOTBALL | yes | yes | yes | | -| SOCCER | yes | yes | | | -| GOLF | yes | yes | yes | | -| GYMNASTICS | yes | yes | yes | | -| HANDBALL | yes | yes | yes | | -| HIGH_INTENSITY_INTERVAL_TRAINING | yes | yes | yes | | -| HIKING | yes | yes | yes | | -| HOCKEY | yes | yes | | | -| SKATING | yes | yes | yes | On iOS this is skating_sports | -| JUMP_ROPE | yes | yes | | | -| KICKBOXING | yes | yes | | | -| MARTIAL_ARTS | yes | yes | yes | | -| PILATES | yes | yes | yes | | -| RACQUETBALL | yes | yes | yes | | -| RUGBY | yes | yes | yes | | -| RUNNING | yes | yes | yes | | -| ROWING | yes | yes | yes | | -| SAILING | yes | yes | yes | | -| CROSS_COUNTRY_SKIING | yes | yes | | | -| DOWNHILL_SKIING | yes | yes | | | -| SNOWBOARDING | yes | yes | yes | | -| SOFTBALL | yes | yes | yes | | -| SQUASH | yes | yes | yes | | -| STAIR_CLIMBING | yes | yes | yes | | -| SWIMMING | yes | yes | | | -| TABLE_TENNIS | yes | yes | yes | | -| TENNIS | yes | yes | yes | | -| VOLLEYBALL | yes | yes | yes | | -| WALKING | yes | yes | yes | | -| WATER_POLO | yes | yes | yes | | -| YOGA | yes | yes | yes | | -| BOWLING | yes | | | | -| CROSS_TRAINING | yes | | | | -| TRACK_AND_FIELD | yes | | | | -| DISC_SPORTS | yes | | | | -| LACROSSE | yes | | | | -| PREPARATION_AND_RECOVERY | yes | | | | -| FLEXIBILITY | yes | | | | -| COOLDOWN | yes | | | | -| WHEELCHAIR_WALK_PACE | yes | | | | -| WHEELCHAIR_RUN_PACE | yes | | | | -| HAND_CYCLING | yes | | | | -| CORE_TRAINING | yes | | | | -| FUNCTIONAL_STRENGTH_TRAINING | yes | | | | -| TRADITIONAL_STRENGTH_TRAINING | yes | | | | -| MIXED_CARDIO | yes | | | | -| STAIRS | yes | | | | -| STEP_TRAINING | yes | | | | -| FITNESS_GAMING | yes | | | | -| BARRE | yes | | | | -| CARDIO_DANCE | yes | | | | -| SOCIAL_DANCE | yes | | | | -| MIND_AND_BODY | yes | | | | -| PICKLEBALL | yes | | | | -| CLIMBING | yes | | | | -| EQUESTRIAN_SPORTS | yes | | | | -| FISHING | yes | | | | -| HUNTING | yes | | | | -| PLAY | yes | | | | -| SNOW_SPORTS | yes | | | | -| PADDLE_SPORTS | yes | | | | -| SURFING_SPORTS | yes | | | | -| WATER_FITNESS | yes | | | | -| WATER_SPORTS | yes | | | | -| TAI_CHI | yes | | | | -| WRESTLING | yes | | | | -| AEROBICS | | yes | | | -| BIATHLON | | yes | | | -| CALISTHENICS | | yes | yes | | -| CIRCUIT_TRAINING | | yes | | | -| CROSS_FIT | | yes | | | -| DANCING | | yes | yes | | -| DIVING | | yes | | | -| ELEVATOR | | yes | | | -| ERGOMETER | | yes | | | -| ESCALATOR | | yes | | | -| FRISBEE_DISC | | yes | yes | | -| GARDENING | | yes | | | -| GUIDED_BREATHING | | yes | yes | | -| HORSEBACK_RIDING | | yes | | | -| HOUSEWORK | | yes | | | -| INTERVAL_TRAINING | | yes | | | -| IN_VEHICLE | | yes | | | -| KAYAKING | | yes | | | -| KETTLEBELL_TRAINING | | yes | | | -| KICK_SCOOTER | | yes | | | -| KITE_SURFING | | yes | | | -| MEDITATION | | yes | | | -| MIXED_MARTIAL_ARTS | | yes | | | -| P90X | | yes | | | -| PARAGLIDING | | yes | yes | | -| POLO | | yes | | | -| ROCK_CLIMBING | (yes) | yes | yes | on iOS this will be stored as CLIMBING | -| RUNNING_JOGGING | (yes) | yes | | on iOS this will be stored as RUNNING | -| RUNNING_SAND | (yes) | yes | | on iOS this will be stored as RUNNING | -| RUNNING_TREADMILL | (yes) | yes | yes | on iOS this will be stored as RUNNING | -| SCUBA_DIVING | | yes | yes | | -| SKATING_CROSS | (yes) | yes | | on iOS this will be stored as SKATING | -| SKATING_INDOOR | (yes) | yes | | on iOS this will be stored as SKATING | -| SKATING_INLINE | (yes) | yes | | on iOS this will be stored as SKATING | -| SKIING_BACK_COUNTRY | | yes | | | -| SKIING_KITE | | yes | | | -| SKIING_ROLLER | | yes | | | -| SLEDDING | | yes | | | -| STAIR_CLIMBING_MACHINE | | yes | yes | | -| STANDUP_PADDLEBOARDING | | yes | | | -| STILL | | yes | | | -| STRENGTH_TRAINING | | yes | yes | | -| SURFING | | yes | yes | | -| SWIMMING_OPEN_WATER | | yes | yes | | -| SWIMMING_POOL | | yes | yes | | -| TEAM_SPORTS | | yes | | | -| TILTING | | yes | | | -| TREADMILL | | yes | | | -| VOLLEYBALL_BEACH | | yes | | | -| VOLLEYBALL_INDOOR | | yes | | | -| WAKEBOARDING | | yes | | | -| WALKING_FITNESS | | yes | | | -| WALKING_NORDIC | | yes | | | -| WALKING_STROLLER | | yes | | | -| WALKING_TREADMILL | | yes | | | -| WEIGHTLIFTING | | yes | yes | | -| WHEELCHAIR | | yes | yes | | -| WINDSURFING | | yes | | | -| ZUMBA | | yes | | | -| OTHER | yes | yes | | | +| -------------------------------- | ------- | ----------------------- | ---------------------------- | ----------------------------------------------------------------- | +| ARCHERY | yes | yes | | | +| BADMINTON | yes | yes | yes | | +| BASEBALL | yes | yes | yes | | +| BASKETBALL | yes | yes | yes | | +| BIKING | yes | yes | yes | on iOS this is CYCLING, but name changed here to fit with Android | +| BOXING | yes | yes | yes | | +| CRICKET | yes | yes | yes | | +| CURLING | yes | yes | | | +| ELLIPTICAL | yes | yes | yes | | +| FENCING | yes | yes | yes | | +| AMERICAN_FOOTBALL | yes | yes | yes | | +| AUSTRALIAN_FOOTBALL | yes | yes | yes | | +| SOCCER | yes | yes | | | +| GOLF | yes | yes | yes | | +| GYMNASTICS | yes | yes | yes | | +| HANDBALL | yes | yes | yes | | +| HIGH_INTENSITY_INTERVAL_TRAINING | yes | yes | yes | | +| HIKING | yes | yes | yes | | +| HOCKEY | yes | yes | | | +| SKATING | yes | yes | yes | On iOS this is skating_sports | +| JUMP_ROPE | yes | yes | | | +| KICKBOXING | yes | yes | | | +| MARTIAL_ARTS | yes | yes | yes | | +| PILATES | yes | yes | yes | | +| RACQUETBALL | yes | yes | yes | | +| RUGBY | yes | yes | yes | | +| RUNNING | yes | yes | yes | | +| ROWING | yes | yes | yes | | +| SAILING | yes | yes | yes | | +| CROSS_COUNTRY_SKIING | yes | yes | | | +| DOWNHILL_SKIING | yes | yes | | | +| SNOWBOARDING | yes | yes | yes | | +| SOFTBALL | yes | yes | yes | | +| SQUASH | yes | yes | yes | | +| STAIR_CLIMBING | yes | yes | yes | | +| SWIMMING | yes | yes | | | +| TABLE_TENNIS | yes | yes | yes | | +| TENNIS | yes | yes | yes | | +| VOLLEYBALL | yes | yes | yes | | +| WALKING | yes | yes | yes | | +| WATER_POLO | yes | yes | yes | | +| YOGA | yes | yes | yes | | +| BOWLING | yes | | | | +| CROSS_TRAINING | yes | | | | +| TRACK_AND_FIELD | yes | | | | +| DISC_SPORTS | yes | | | | +| LACROSSE | yes | | | | +| PREPARATION_AND_RECOVERY | yes | | | | +| FLEXIBILITY | yes | | | | +| COOLDOWN | yes | | | | +| WHEELCHAIR_WALK_PACE | yes | | | | +| WHEELCHAIR_RUN_PACE | yes | | | | +| HAND_CYCLING | yes | | | | +| CORE_TRAINING | yes | | | | +| FUNCTIONAL_STRENGTH_TRAINING | yes | | | | +| TRADITIONAL_STRENGTH_TRAINING | yes | | | | +| MIXED_CARDIO | yes | | | | +| STAIRS | yes | | | | +| STEP_TRAINING | yes | | | | +| FITNESS_GAMING | yes | | | | +| BARRE | yes | | | | +| CARDIO_DANCE | yes | | | | +| SOCIAL_DANCE | yes | | | | +| MIND_AND_BODY | yes | | | | +| PICKLEBALL | yes | | | | +| CLIMBING | yes | | | | +| EQUESTRIAN_SPORTS | yes | | | | +| FISHING | yes | | | | +| HUNTING | yes | | | | +| PLAY | yes | | | | +| SNOW_SPORTS | yes | | | | +| PADDLE_SPORTS | yes | | | | +| SURFING_SPORTS | yes | | | | +| WATER_FITNESS | yes | | | | +| WATER_SPORTS | yes | | | | +| TAI_CHI | yes | | | | +| WRESTLING | yes | | | | +| AEROBICS | | yes | | | +| BIATHLON | | yes | | | +| CALISTHENICS | | yes | yes | | +| CIRCUIT_TRAINING | | yes | | | +| CROSS_FIT | | yes | | | +| DANCING | | yes | yes | | +| DIVING | | yes | | | +| ELEVATOR | | yes | | | +| ERGOMETER | | yes | | | +| ESCALATOR | | yes | | | +| FRISBEE_DISC | | yes | yes | | +| GARDENING | | yes | | | +| GUIDED_BREATHING | | yes | yes | | +| HORSEBACK_RIDING | | yes | | | +| HOUSEWORK | | yes | | | +| INTERVAL_TRAINING | | yes | | | +| IN_VEHICLE | | yes | | | +| KAYAKING | | yes | | | +| KETTLEBELL_TRAINING | | yes | | | +| KICK_SCOOTER | | yes | | | +| KITE_SURFING | | yes | | | +| MEDITATION | | yes | | | +| MIXED_MARTIAL_ARTS | | yes | | | +| P90X | | yes | | | +| PARAGLIDING | | yes | yes | | +| POLO | | yes | | | +| ROCK_CLIMBING | (yes) | yes | yes | on iOS this will be stored as CLIMBING | +| RUNNING_JOGGING | (yes) | yes | | on iOS this will be stored as RUNNING | +| RUNNING_SAND | (yes) | yes | | on iOS this will be stored as RUNNING | +| RUNNING_TREADMILL | (yes) | yes | yes | on iOS this will be stored as RUNNING | +| SCUBA_DIVING | | yes | yes | | +| SKATING_CROSS | (yes) | yes | | on iOS this will be stored as SKATING | +| SKATING_INDOOR | (yes) | yes | | on iOS this will be stored as SKATING | +| SKATING_INLINE | (yes) | yes | | on iOS this will be stored as SKATING | +| SKIING_BACK_COUNTRY | | yes | | | +| SKIING_KITE | | yes | | | +| SKIING_ROLLER | | yes | | | +| SLEDDING | | yes | | | +| STAIR_CLIMBING_MACHINE | | yes | yes | | +| STANDUP_PADDLEBOARDING | | yes | | | +| STILL | | yes | | | +| STRENGTH_TRAINING | | yes | yes | | +| SURFING | | yes | yes | | +| SWIMMING_OPEN_WATER | | yes | yes | | +| SWIMMING_POOL | | yes | yes | | +| TEAM_SPORTS | | yes | | | +| TILTING | | yes | | | +| TREADMILL | | yes | | | +| VOLLEYBALL_BEACH | | yes | | | +| VOLLEYBALL_INDOOR | | yes | | | +| WAKEBOARDING | | yes | | | +| WALKING_FITNESS | | yes | | | +| WALKING_NORDIC | | yes | | | +| WALKING_STROLLER | | yes | | | +| WALKING_TREADMILL | | yes | | | +| WEIGHTLIFTING | | yes | yes | | +| WHEELCHAIR | | yes | yes | | +| WINDSURFING | | yes | | | +| ZUMBA | | yes | | | +| OTHER | yes | yes | | | \ No newline at end of file diff --git a/packages/health/ios/Classes/SwiftHealthPlugin.swift b/packages/health/ios/Classes/SwiftHealthPlugin.swift index 8e7e9845e..efc83f371 100644 --- a/packages/health/ios/Classes/SwiftHealthPlugin.swift +++ b/packages/health/ios/Classes/SwiftHealthPlugin.swift @@ -70,7 +70,6 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { let HEADACHE_SEVERE = "HEADACHE_SEVERE" let ELECTROCARDIOGRAM = "ELECTROCARDIOGRAM" let NUTRITION = "NUTRITION" - let STAND_TIME = "STAND_TIME" // Health Unit types // MOLE_UNIT_WITH_MOLAR_MASS, // requires molar mass input - not supported yet @@ -430,7 +429,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { 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( [blood_pressure_sample], withCompletion: { (success, error) in @@ -616,8 +615,6 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { var predicate = HKQuery.predicateForSamples( withStart: dateFrom, end: dateTo, options: .strictStartDate) - let watchPredicate = HKQuery.predicateForObjects(withDeviceProperty: HKDevicePropertyKeyModel, allowedValues: ["Watch"]) - let combinedPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [predicate, watchPredicate]) if (!includeManualEntry) { let manualPredicate = NSPredicate(format: "metadata.%K != YES", HKMetadataKeyWasUserEntered) predicate = NSCompoundPredicate(type: .and, subpredicates: [predicate, manualPredicate]) @@ -625,7 +622,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false) let query = HKSampleQuery( - sampleType: dataType, predicate: combinedPredicate, limit: limit, sortDescriptors: [sortDescriptor] + sampleType: dataType, predicate: predicate, limit: limit, sortDescriptors: [sortDescriptor] ) { [self] x, samplesOrNil, error in @@ -1202,7 +1199,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { dataTypesDict[WORKOUT] = HKSampleType.workoutType() dataTypesDict[NUTRITION] = HKSampleType.correlationType( forIdentifier: .food)! - dataTypesDict[STAND_TIME] = HKSampleType.quantityType(forIdentifier: .appleStandTime) + healthDataTypes = Array(dataTypesDict.values) } diff --git a/packages/health/lib/src/heath_data_types.dart b/packages/health/lib/src/heath_data_types.dart index 4e683dfff..37ca9b5cd 100644 --- a/packages/health/lib/src/heath_data_types.dart +++ b/packages/health/lib/src/heath_data_types.dart @@ -56,7 +56,6 @@ enum HealthDataType { HEADACHE_SEVERE, HEADACHE_UNSPECIFIED, NUTRITION, - STAND_TIME, // Heart Rate events (specific to Apple Watch) HIGH_HEART_RATE_EVENT, @@ -131,7 +130,6 @@ const List dataTypeKeysIOS = [ HealthDataType.HEADACHE_UNSPECIFIED, HealthDataType.ELECTROCARDIOGRAM, HealthDataType.NUTRITION, - HealthDataType.STAND_TIME, ]; /// List of data types available on Android @@ -236,7 +234,6 @@ const Map dataTypeToUnit = { HealthDataType.ELECTROCARDIOGRAM: HealthDataUnit.VOLT, HealthDataType.NUTRITION: HealthDataUnit.NO_UNIT, - HealthDataType.STAND_TIME: HealthDataUnit.MINUTE, // Health Connect HealthDataType.TOTAL_CALORIES_BURNED: HealthDataUnit.KILOCALORIE, From f40f30a6ba9ea6d824c5cd4b4f1961e55485b7dd Mon Sep 17 00:00:00 2001 From: ikoamu Date: Mon, 1 Apr 2024 00:21:03 +0900 Subject: [PATCH 6/6] Add missing newline at end of file --- packages/health/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/health/README.md b/packages/health/README.md index e37d43a7e..9a6ebc06c 100644 --- a/packages/health/README.md +++ b/packages/health/README.md @@ -473,4 +473,4 @@ The plugin supports the following [`HealthWorkoutActivityType`](https://pub.dev/ | WHEELCHAIR | | yes | yes | | | WINDSURFING | | yes | | | | ZUMBA | | yes | | | -| OTHER | yes | yes | | | \ No newline at end of file +| OTHER | yes | yes | | |