rn-apple-healthkit icon indicating copy to clipboard operation
rn-apple-healthkit copied to clipboard

Getting Workout data does not work

Open ix42 opened this issue 5 years ago • 3 comments

Getting workout data does not seem to work properly. Can you please check the code if Workout permissions are properly handled?

Running the following code:

const options = { read: [ PERM.Workout ] }
AppleHealthKit.initHealthKit(options, (err, results) => {
   console.log(err);
})

const wopt = {
  startDate: (new Date(2020,5,17)).toISOString(),
  endDate: (new Date()).toISOString(),
  type: 'Workout'
}
AppleHealthKit.getSamples(wopt, (err, results) => {
  console.log(err);
})

Behavior:

  • getSamples() fails with "error getting samples"
  • initHealthKit() runs with no error. Also, no permissioning dialog pops up on the phone
  • phone console message says that authorization was not granted ("Authorization not determined"

Might be linked to the fact that RCTAppleHealthKit+TypesAndPermissions.m returns nil for "Workout"

Thank you

ix42 avatar May 18 '20 18:05 ix42

I've run into the same problem. getSamples returns "error getting samples", while other methods, like getFlightsClimbed(), getStepCount() or getSleepSamples() return real data.

@ix42 , have you found a solution to this issue?

agnieszkabugla avatar May 28 '20 10:05 agnieszkabugla

Yes, i went for another fork of the project, you can check my fork or the one from https://github.com/nutrisense

Actually the best version of rn-apple-healthkit would theoretically be one in which the main repo would sync with the work done by nutrisense (kudos to both)

ix42 avatar May 28 '20 13:05 ix42

I am also getting this error, I believe if it because PERMS.Workout doesn't actually request permission to access workouts. When I install https://github.com/nutrisense/rn-apple-healthkit and get that library to request access and then switch back to this library it then works.

This fixed it for me https://github.com/maxstudener/rn-apple-healthkit/commit/2f654633bbbe1b153d61907ad3cca388bd92c542

maxstudener avatar Nov 03 '20 04:11 maxstudener