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: 11.1.0] Delete not working on iOS #1085

Open
Fethi-Hamdani opened this issue Nov 22, 2024 · 1 comment
Open

[Health: 11.1.0] Delete not working on iOS #1085

Fethi-Hamdani opened this issue Nov 22, 2024 · 1 comment
Labels
bugfix a bug fix

Comments

@Fethi-Hamdani
Copy link

Plugin Name

health

Plugin Version

11.1.0

Device

Iphone 13 pro max

Operating System

iOS 18.1

Describe the bug

Due to Apple's Limitations on knowing the Read/Write permissions to Apple Health steps, I added a workaround to manually check the permission by writing a dummy data and deleting it, the return value is always false even though I made sure the value is available in Apple Health and being read normally

Steps to Reproduce

1 - Save a dummy data (0 steps) on a specified start and end date
2 - Read the dummy data using the same start and end date (confirm it is available)
3 - Delete the dummy data using the same start and end date

Expected Behavior

The delete function return type should be true and the value should be delete from Apple Health

Actual Behavior

The delete function return type is always false and the value is still available on Apple Health

Flutter Logs

No response

Screenshots

No response

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.22.3, on macOS 15.0.1 24A348 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.95.3)
[✓] Connected device (4 available)
[✓] Network resources

Additional Information

No response

@Fethi-Hamdani Fethi-Hamdani added the bugfix a bug fix label Nov 22, 2024
@Fethi-Hamdani Fethi-Hamdani changed the title [<Health> <11.1.0>] Delete not working on iOS [Health: 11.1.0] Delete not working on iOS Nov 22, 2024
@ifuterman
Copy link
Contributor

I found a solution and found a bug. If you don't specify an end date inside the plugin, they use the same date, and Apple Health can't find a date to delete. Use a date like in my example, it works
BugFix:

final testWrite = DateTime.now();
final w = await health.writeHealthData(value: 1, type: HealthDataType.STEPS, startTime: testWrite);//w = true
final d = await health.delete(type: HealthDataType.STEPS, startTime: testWrite, endTime: DateTime.now());//d = true

A more correct way to fix the issue is to use different function in a swift side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix a bug fix
Projects
None yet
Development

No branches or pull requests

2 participants