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

Incorrect metadata key name for deduplicating records #38

Open
mordechaim opened this issue Nov 7, 2022 · 3 comments
Open

Incorrect metadata key name for deduplicating records #38

mordechaim opened this issue Nov 7, 2022 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mordechaim
Copy link

mordechaim commented Nov 7, 2022

https://github.com/Kingstinct/react-native-healthkit/blob/49c81d7fcf75e7e970c6841696c858a5d0e73ce5/src/native-types.ts#L328-L329

According to Apple, the correct names are HKMetadataKeySyncIdentifier and HKMetadataKeySyncVersion. I actually tried both key names, but only the HKMetadataKeyXXX key correctly deduplicated the data.

Thanks for this amazing library; it's the most comprehensive react native bridge for HealthKit ❤️

EDIT: I now notice other keys missing the MetadataKey prefix, such as HKMetadataKeyReferenceRangeLowerLimit

@robertherber robertherber added the good first issue Good for newcomers label Nov 7, 2022
@robertherber
Copy link
Member

robertherber commented Nov 7, 2022

Thanks @mordechaim! :)

I'd be superhappy for a PR on this. Since it's JSON being sent over the native bridge - just updating the TypeScript types to reflect the Apple recommended metadata keys should result in expected behaviour here.

@robertherber robertherber added the bug Something isn't working label Nov 9, 2022
@robertherber
Copy link
Member

I'm not quite sure about which naming convention is being used by Apple here actually. On my sleep samples I'm getting HKTimeZone and not HKMetadataKeyTimeZone, and that's coming straight from Apple Watch.

The data you're looking at - is it coming from Apple or from another data source @mordechaim? I think the docs and actual keys used by Apple might have confused not only us - but other developers using HealthKit as well.

@mordechaim
Copy link
Author

This is indeed confusing.

I'm pushing to HealthKit and in order to deduplicate data (sending over an updated step count for the hour will add instead of update) I need to pass the 2 keys mentioned above. I tried using the keys without HKMetadata* prefix and it did not properly deduplicate.

(Sorry for not following up with a PR, I'm not a TypeScript guy and fear I'll do it incorrectly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants