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

Cannot read body fat percentage..

Open shrinandhini2801 opened this issue 6 years ago • 2 comments

Unable to read body fat percentage even though there is a method in doc ==> AppleHealthKit.getLatestBodyFatPercentage.

Am getting below error

{"message":"error getting latest body fat percentageError Domain=com.apple.healthkit Code=5 \"Authorization not determined\" UserInfo={NSLocalizedDescription=Authorization not determined}"}

shrinandhini2801 avatar Jul 25 '18 12:07 shrinandhini2801

did you find any solution?

raginisahu avatar May 02 '19 13:05 raginisahu

When you run AppleHealthKit.initHealthKit(options, (err, results), you need to pass an options object, which should contain a read property that contains all the stuff you want read access to. You just need to add body fat in that list, like so:

https://github.com/terrillo/rn-apple-healthkit/blob/master/docs/initHealthKit().md

const healthKitOptions = {
  permissions: {
    read: ['BodyFatPercentage']
  }
};

Considering that permission to read BodyFatPercentage may not have been granted, you might also want to consider running AppleHealthKit.authorizationStatusForType() beforehand.

https://github.com/terrillo/rn-apple-healthkit/blob/master/docs/authorizationStatusForType().md

Luke-Gurgel avatar Sep 11 '19 18:09 Luke-Gurgel