Open Johan-dutoit opened 3 years ago
Hello,
I started adding these data types to the package, however I cannot find any information as of why Apple allows only writing to Health for those data types.
What is your use case? Have you came across information as to why you can't read these data types from Health?
Hey @fakeheal, I completely skipped checking PR's to see if someone has implemented this yet (my apologies).
My use case, is that I'm working on a fitness app that takes a users cycle into consideration. My guess was I had to query HKCategoryTypeIdentifierMenstrualFlow
.
Based on https://github.com/skooal/HealthKitUsageDemo, it seems that it is readable?
If it helps, here's the code
Thank you so much for the clarification, @Johan-dutoit! Silly me, I have added the permissions in the getWritePermFromText
, but not in getReadPermFromText
in RCTAppleHealthKit+TypesAndPermissions.m
.
I have fixed that mistake in my fork @ support-for-reproductive-health and I have added two methods:
You can test my changes by adding, my repo+branch as dependency in your project:
yarn add https://github.com/fakeheal/react-native-health#support-for-reproductive-health
I am fairly new in this as well, but if you follow my commits and the changed files in them, you can see the "steps":
RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_ReproductiveHealth.h
RCTAppleHealthKit.m
For testing, while developing features/debugging/etc, I have this repository checked out twice:
./react-native-health
./react-native-health-example
In the example repository, go to example/
folder and do yarn add ../../react-native-health
, this will add your local folder as dependency. Then you can edit files in react-native-health
(and use git to keep track of your changes) and then do yarn add
again, to update your example
repository and build the app in xcode.
Also, this is my code that you can use to test the methods I added: App.tsx
I'm going to give this a go right now, thanks for your efforts!
Here is what I managed to do
After some testing, I got the following feedback
Missing types
Other
Hey, @Johan-dutoit,
Successfully queried data (well, I got an empty array), Successfully requested write permission (although couldn't find the write function, I was only going to use it to insert test data, used the health app to add test data instead)
You can add data manually using the Health app, to see if its fetched properly. Write functions are yet to be implemented, so this is the only way to add data right now (or use another app that writes those data types).
Missing types, Reproductive Function types, etc...
I think those are missing, because package's js/ts is yet to be bundled.
I can confirm nothing but success for what I've tried. Thanks.
I am glad it works! Thank you for testing!
What other data types are you using in your project? Maybe we can split the work on adding the other functionality related to Reproductive Health? I can add methods for adding data for HKCategoryTypeIdentifierMenstrualFlow
, so you can see it and use as template?
Or you can help with testing the methods I add?
At the moment it's purely HKCategoryTypeIdentifierMenstrualFlow
, however I'm more than happy to split it up once you have a template in place?
@Johan-dutoit @fakeheal is there an update on this topic? is there a plan for it to be integrated at some point?
Hello 👋
For an app I did (My PrEP) I would also be very interested in being able to write sexual activity to Apple HealthKit 🙏 .
Thanks!
Hello, I actually require this data type for my app.
Is the suggested method here the current solution? Or are there any plans to add it to the current library.
@GGGava @Johan-dutoit @fakeheal
It seems
Reproductive Health
has completely been missedI'm specifically interested in
HKCategoryTypeIdentifierMenstrualFlow
but the others missing areI don't have much experience with Health Kit, but if someone can guide me on one, I can use that as a template for the rest.