lucaspbordignon / rn-apple-healthkit

A React Native package for interacting with Apple HealthKit
https://www.npmjs.com/package/react-native-health
MIT License
520 stars 296 forks source link

Filter manual entered data #28

Open AadGlasbergen opened 6 years ago

AadGlasbergen commented 6 years ago

We are developing an App which give you "Coins" when you reached an achievement. You can manually enter step in Health Kit. Is it possible to filter out this manual entered data.

neogermi commented 6 years ago

Hi @AadGlasbergen have you found a solution in the meantime? We are facing the same issue.

psousa commented 5 years ago

Yeah, being able to get the "source" of the data is a must for me.

JulianKingman commented 5 years ago

If anyone's interested in submitting a PR, this is the function to update: https://github.com/terrillo/rn-apple-healthkit/blob/master/RCTAppleHealthKit/RCTAppleHealthKit%2BQueries.m#L292

I think it could be made to accept and return sources.

psousa commented 5 years ago

Thanks. So it would be just a matter of optionally joining 2 NSPredicates? The existing one with the dates and another to ignore manual data, something like this: NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];

JulianKingman commented 5 years ago

I'm still pretty new to Objective C, but this looks like a pretty good place to start: https://developer.apple.com/documentation/healthkit/hkstatisticsoptions?language=objc

thegamenicorus commented 5 years ago

Hi guys,

Its been a while since this issue has opened and today I'm facing the same issue with you guys 😅 .

So, please check this my PR >> #74 . Its quick (and probably dirty) fix by add new param 'skipManual' in options.

const options = {
    date: new Date().toISOString(),
    skipManual: true
  };
  AppleHealthKit.getStepCount(options, (err, results) => {
    if (err) {
      return 0;
    }
    ...other actions
  });
psousa commented 5 years ago

@thegamenicorus that's awesome!