Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Health 12.0.1] Support for PERMISSION_READ_HEALTH_DATA_HISTORY in Health Connect #1126

Open
cachapa opened this issue Feb 3, 2025 · 3 comments · Fixed by #1127
Open

[Health 12.0.1] Support for PERMISSION_READ_HEALTH_DATA_HISTORY in Health Connect #1126

cachapa opened this issue Feb 3, 2025 · 3 comments · Fixed by #1127
Assignees
Labels
improvement an improvement

Comments

@cachapa
Copy link
Contributor

cachapa commented Feb 3, 2025

Description

Health Connect on Android now allows for downloading over 30 days worth of data, but that requires requesting a new permission: PERMISSION_READ_HEALTH_DATA_HISTORY: Documentation.

Although this can be added manually by apps, it would be a nice addition to the Health plugin.

@cachapa cachapa added the improvement an improvement label Feb 3, 2025
cachapa added a commit to cachapa/flutter-plugins that referenced this issue Feb 3, 2025
Created two new methods isHealthDataHistoryAuthorized() and
requestHealthDataHistoryAuthorization().

Both methods are no-op on iOS and return true since Apple Health does
not restrict history length.

Closes cph-cachet#1126
@henryla92
Copy link

Description

Health Connect on Android now allows for downloading over 30 days worth of data, but that requires requesting a new permission: PERMISSION_READ_HEALTH_DATA_HISTORY: Documentation.

Although this can be added manually by apps, it would be a nice addition to the Health plugin.

Thank you for suggesting this addition and making the pull request!

I was hoping to add this on my app right now, can you please explain how I would add this manually? I added
<uses-permission android:name="android.permission.health.PERMISSION_READ_HEALTH_DATA_HISTORY"/> in my AndroidManifest, how would I update to implementation("androidx.health.connect:connect-client:1.1.0-alpha11") within my app?

Thank you!

@cachapa
Copy link
Contributor Author

cachapa commented Feb 15, 2025

If you use my branch, the connect-client dependency is already updated. You might need to refresh your build with flutter clean.

Please note that you should first check if the feature is even available, or risk crashing your app when trying to use it:
isHealthDataHistoryAvailable().

Once you do that you will need to request that permission separately using requestHealthDataHistoryAuthorization(). It shows a separate permission screen, so it cannot be bundled with other permission requests.

@henryla92
Copy link

Thank you!

@iarata iarata self-assigned this Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement an improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants