-
Notifications
You must be signed in to change notification settings - Fork 675
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
Allow to record meal data (macro nutrients) #679
Allow to record meal data (macro nutrients) #679
Conversation
Wow! Cool improvement!!! What about read nutrition data? I only can see write that information. |
Thanks! Didn't add read support on this pr, but it should be pretty straightforward to do it if you want to contribute as well. I think it's only a matter of adding the nutrition types you want to read and mapping then to units and the package should be able to parse them as numeric health values. What do you think? |
I would love to be able to do that! Unfortunately, I'm a novice programmer and just starting to make my first apps 😔 . Although I would be very grateful if you could add read and write the whole nutritional topic. https://developer.apple.com/documentation/healthkit/data_types/nutrition_type_identifiers |
Unfortunately, I don't have the time to add more features right now, maybe you should open an issue with that feature request? Btw the package already supports reading the macronutrients at least on iOS: So it should be easy to add support for more types based on the existing code if you have time even if you're a novice... Just take a look at the source code 😉 |
I added it a month ago... Thank you for that link. I see, so only needs to add the micronutrients. Thank you for your time! |
@JuanFcoRomero you can see how those were added in the past: 668b419 and that should give you an insight on how to add more. If you want to also take a look, for Android/Google Fit it works a bit different. There's only one type If you add more don't forget to contribute and open a pull request 👍 |
Thank you so much! I will study the code! |
@MadsVSChristensen sorry to tag you, but just wanted to ask if it's possible to consider this pull request for future releases? Cheers |
Any updates on this? |
Hello @biklas7, thank you for the PR! |
Thank you so much @hoffmatteo that's great news! ❤️ I don't want to sound pushy or bite the hand that feeds 😅 but if you could take a look into this one as well #675 it would be awesome! It just adds Insulin data type for iOS (not available for Android) so it's a really small PR and doesn't require too many changes on your side (I think) 🙏 This way we could stop using our outdated fork and finally use this package to it's full potential 👍 |
@biklas7 |
@hoffmatteo Of course! No rush! Take whatever time you need 👍 The most important thing is that's on the roadmap! |
@hoffmatteo any idea when it's gonna be possible to close this? |
} | ||
|
||
if #available(iOS 15.0, *){ | ||
let meal = HKCorrelation.init(type: HKCorrelationType.init(HKCorrelationTypeIdentifier.food), start: dateFrom, end: dateTo, objects: nutrition, metadata: metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let meal = HKCorrelation.init(type: HKCorrelationType.init(HKCorrelationTypeIdentifier.food), start: dateFrom, end: dateTo, objects: nutrition, metadata: metadata) | |
let type = HKCorrelationType.correlationType(forIdentifier: HKCorrelationTypeIdentifier.food)! | |
let meal = HKCorrelation(type: type, start: dateFrom, end: dateTo, objects: nutrition, metadata: metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discovered a crash on iOS 16 and this fixes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoffmatteo Please confirm if you don't need this fix. This caused a crash on our fork.
Hi! |
Hi @hoffmatteo glad to hear you're working on this. If you need something let me know! Hope your changes land soon 🤞 |
@biklas7 I just pushed my changes, sorry for the long wait! Please feel free to review them and let me know your thoughts. |
} | ||
|
||
if #available(iOS 15.0, *){ | ||
let meal = HKCorrelation.init(type: HKCorrelationType.init(HKCorrelationTypeIdentifier.food), start: dateFrom, end: dateTo, objects: nutrition, metadata: metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoffmatteo Please confirm if you don't need this fix. This caused a crash on our fork.
Thanks, everything looks good to me, I just pointed out a few things for you to double-check before merging this, but other than that, it looks good! Thanks for updating the code and working on this feature 👍 |
Closes #680