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

Saving HKCategory to HK #88

Open
manuelnaturalcycles opened this issue Feb 23, 2017 · 6 comments
Open

Saving HKCategory to HK #88

manuelnaturalcycles opened this issue Feb 23, 2017 · 6 comments

Comments

@manuelnaturalcycles
Copy link

manuelnaturalcycles commented Feb 23, 2017

window.plugins.healthkit.saveQuantitySample(
  {
    startDate: date, // point in time means that endDate = startDate
    endDate: date, // now
    sampleType: 'HKCategoryTypeIdentifierSexualActivity',
    amount: '0',
    unit: 'count',
    metadata: {
      HKSexualActivityProtectionUsed: protectionUsed
    }
  }, function (r) {
    $log.debug('Wrote data to HK with sex for date: ' + date)
  }, function (e) {
    alert('error: ' + e)
    $log.error(e)
  }
);

I cant save Sexual Activity because it asks for a unit. How should I handle saving data which is not really a quantity sample but a Category?

@EddyVerbruggen
Copy link
Owner

Looks like the plugin needs to be altered a bit for this type of usage. Apple doc.

@manuelnaturalcycles
Copy link
Author

manuelnaturalcycles commented Feb 23, 2017

I see.

I have an old version of the plugin forked from this one which actually had a saveCategorySample method implemented.

Was this removed for any specific reason?

I will work on this modification to see if i can make it happen.

thanks!

@EddyVerbruggen
Copy link
Owner

Perhaps it was removed by a PR, not intentionally IIRC.

@manuelnaturalcycles
Copy link
Author

Oj! That seems unfortunate, it was a cool feature.

@manuelnaturalcycles
Copy link
Author

Hej @EddyVerbruggen I successfully readded the functionality in this fork https://github.com/manuelnaturalcycles/HealthKit
I am a bit lost as to how to structure the code that I added so that you would even consider merging it into real branch, is there any guide i should use?

@EddyVerbruggen
Copy link
Owner

Hi @manuelnaturalcycles your code looks good. I may need to tweak a little thingy after merging but that's not an issue.

Do you have a JS sample I can test this method with perhaps?

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

No branches or pull requests

2 participants