Skip to content

Write data returns String? uuid instead of boolean - #448

Merged
iarata merged 8 commits into
carp-dk:devfrom
agilst:write-data-return-uuid
Aug 14, 2026
Merged

iarata merged 8 commits into
carp-dk:devfrom
agilst:write-data-return-uuid

Conversation

@agilst

@agilst agilst commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

This PR is recreated from carp-dk/flutter-plugins#1241, and there are some adjustment to inline documentations.

writeHealthData and writeWorkoutData is now returns String? uuid using InsertRecordsResponse.recordIdsList.firstOrNull() on Android and HKObject.uuid.uuidString on iOS. Please note that there is no extra efforts added when writing health data.

This is useful for some apps that need to utilise uuid once successfully writing health data (e.g. store into database for future use).

- Update `writeData` to return string `uuid`
- Update `writeWorkoutData` to return string `uuid`
- Update `writeHealthData` to return string `uuid`
- Update `writeWorkoutData` to return string `uuid`
- Create `addSingleHealthData` to push a dummy steps data
- Create `addSingleWorkoutData ` to push a dummy running data
@kvenn

kvenn commented Nov 3, 2025

Copy link
Copy Markdown

I can imagine this not getting merged because it breaks backwards compatibility. That being said, I think it's necessary and would love if this PR got merged. Especially given that you need the UUID to delete the record (as opposed to the sketchy deletion by time-range).

But in case the maintainers don't want to introduce a breaking change, we could expose two methods. One that returns a boolean and one that returns a string.

But again, I'd advocate for merging this as is (with a corresponding major version bump).

@nooralibutt

Copy link
Copy Markdown

@agilst can you please prioritize this?

ytsni added a commit to ytsni/health_bridge that referenced this pull request May 24, 2026
New features:
- VO2 Max data type support (iOS + Android read/write)
- Mindfulness data type on Android (read/write)
- writeHealthData/writeWorkoutData now return String? UUID instead of bool
  (BREAKING: callers checking `== true` must check `!= null`)
- Swift Package Manager support for iOS (sources moved to
  ios/health/Sources/health/, Package.swift added)
- CocoaPods still works via updated podspec

Cherry-picked from upstream:
- carp-dk#481: VO2 Max
- carp-dk#460: Mindfulness on Android
- carp-dk#448: UUID return from write methods
- carp-dk#488: SPM support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ytsni added a commit to ytsni/health_bridge that referenced this pull request May 24, 2026
New features:
- VO2 Max data type support (iOS + Android read/write)
- Mindfulness data type on Android (read/write)
- writeHealthData/writeWorkoutData now return String? UUID instead of bool
  (BREAKING: callers checking `== true` must check `!= null`)
- Swift Package Manager support for iOS (sources moved to
  ios/health/Sources/health/, Package.swift added)
- CocoaPods still works via updated podspec

Cherry-picked from upstream:
- carp-dk#481: VO2 Max
- carp-dk#460: Mindfulness on Android
- carp-dk#448: UUID return from write methods
- carp-dk#488: SPM support
agilst and others added 5 commits August 12, 2026 16:05
* Add write data to return uuid on iOS and Android
- Add `writeDataUUID` to return string `uuid`
- Add `writeWorkoutDataUUID` to return string `uuid`

* Add health data functions to return uuid
- Add `writeHealthDataUUID` to return string `uuid`
- Add `writeWorkoutDataUUID` to return string `uuid`

* Update example screen
- Create `addSingleHealthData` to push a dummy steps data
- Create `addSingleWorkoutData ` to push a dummy running data

Tested on Android and iOS (passed)
@agilst

agilst commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

I agree with @kvenn. instead of introducing a breaking change, I have created different functions to write data and return UUID and keep the original ones.

@iarata FYI

@iarata
iarata changed the base branch from main to dev August 14, 2026 11:46
@iarata
iarata merged commit 6011d3e into carp-dk:dev Aug 14, 2026
@iarata iarata mentioned this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants