rn-apple-healthkit
rn-apple-healthkit copied to clipboard
Cannot read body fat percentage..
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}"}
did you find any solution?
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