cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
550 stars 674 forks source link

[health 11.0] Requests incorrect permissions #1047

Open traed opened 1 month ago

traed commented 1 month 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

When running Health().requestAuthorization with the types STEPS and WORKOUT only, the types TOTAL_CALORIES_BURNED and DISTANCE_WALKING_RUNNING are also requested. Since they are not specified in our list of types, Health().hasPermissions always returns false, prompting Health().requestAuthorization to run every time we want to access health data.

To Reproduce

const _types = [
  HealthDataType.STEPS,
  HealthDataType.WORKOUT
];

// Triggers a request for permissions including TOTAL_CALORIES_BURNED and DISTANCE_WALKING_RUNNING 
// which were not requested.
await Health().requestAuthorization(_types); 

// Returns false even though the requested permissions are granted. Presumably since it also (for some reason) checks
// TOTAL_CALORIES_BURNED and DISTANCE_WALKING_RUNNING which were granted but not saved.
await Health().hasPermissions(_types);

Expected behavior

Only the specified permissions should be requested.

Actual behavior

TOTAL_CALORIES_BURNED and DISTANCE_WALKING_RUNNING are requested even if not specified.

Flutter doctor

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-SE)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.93.1)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Additional information

According to the data types table, DISTANCE_WALKING_RUNNING isn't even supported on Android, but it's still requested. Why?

ciriousjoker commented 1 month ago

Out app was just rejected from Google because it requires these permissions that are technically not required.

Aqitaniya commented 3 weeks ago

On the IOS the same issue await Health().hasPermissions([HealthDataType.BLOOD_GLUCOSE], permissions: [HealthDataAccess.WRITE]) always return false when in settings allowed. IOS 17.6.1 iPhone 13 mini