cph-cachet / flutter-plugins

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

Fetch workouts from Google Fit (Health 8.1.0 , Health 6 and 7) #879

Open fl0tsch opened 10 months ago

fl0tsch commented 10 months ago

Device / Emulator and OS

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

Describe the bug

Can't fetch workouts from Google Fit (version 2023.11.23). STEPS work find but workouts do not work. I tried different health plugin versions. I

await health.getHealthDataFromTypes(start, end, types); does not return any Workouts.

I checked that in the defined period workouts are logged in Google Fit. I also checked that the user signed in in Google Fit is the same user which I granted access in the App

  static final types = [
   HealthDataType.STEPS,
   HealthDataType.WORKOUT,
  ];

The OAuth client is set up like described and the access is granted in the app. (I can fetch STEPS)

In the android manifest I added the following permissions:

`

<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_DISTANCE" />`

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.13.9, on macOS 13.1 22C65 darwin-arm64, locale en-DE) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.1) [✓] IntelliJ IDEA Community Edition (version 2023.3.2) [✓] VS Code (version 1.85.2) [✓] Connected device (3 available) [✓] Network resources

• No issues found!

fl0tsch commented 10 months ago

I create the HealthFactory object like this:

HealthFactory(useHealthConnectIfAvailable: false);