cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
554 stars 681 forks source link

Health 10.2.0 #1011

Closed niminui closed 3 months ago

niminui commented 3 months ago

How to Upload Heart Rate Variability Data in the Plugin

Device / Emulator and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on:

Describe the bug

I have now implemented the uploading of heart rate, step count, and sleep duration data. Now, I want to upload heart rate variability (HRV) data. I see that there is a READ_HEART_RATE_VARIABILITY permission in the Android documentation. How can I obtain the HRV permission in this plugin?

To Reproduce

List<HealthDataType> healthTypesTemp = [
    HealthDataType.HEART_RATE_VARIABILITY_SDNN,
    HealthDataType.HEART_RATE_VARIABILITY_SDNN,
  ];
List<HealthDataAccess> permissions = [
    HealthDataAccess.READ,
    HealthDataAccess.WRITE,
  ];
try {
  authorized = await Health()
      .requestAuthorization(healthTypesTemp, permissions: permissions);
} catch (e) {
  return false;
}

Expected behavior

I expect authorized to return true.

Actual behavior

However, I actually got this error:

W/FLUTTER_HEALTH::ERROR(18872): Datatype HEART_RATE_VARIABILITY_SDNN not found in HC
SlimShadyIAm commented 3 months ago

Hi @niminui, HRV support is a feature that has not yet been released but will be included in version 11.0.0 in the coming days.

niminui commented 3 months ago

Hi @niminui, HRV support is a feature that has not yet been released but will be included in version 11.0.0 in the coming days.

That's great, thank you! Also, besides heart rate variability, will distance (READ/WRITE_DISTANCE) and exercise (READ/WRITE__EXERCISE) be supported as well? Thanks!

SlimShadyIAm commented 3 months ago

I believe these are already supported. Have you look at the example app?

Distance should be DISTANCE_DELTA, you can read exercise sessions with the WORKOUT type and write it with writeWorkoutData (see the example app for this)

niminui commented 3 months ago

I believe these are already supported. Have you look at the example app?

Distance should be DISTANCE_DELTA, you can read exercise sessions with the WORKOUT type and write it with writeWorkoutData (see the example app for this)

Alright, thank you. It was my oversight for not looking carefully earlier.