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

Filter manual entered data

Open AadGlasbergen opened this issue 6 years ago • 7 comments

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.

AadGlasbergen avatar Mar 23 '18 09:03 AadGlasbergen

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

neogermi avatar Jul 09 '18 11:07 neogermi

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

psousa avatar Nov 26 '18 18:11 psousa

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.

JulianKingman avatar Nov 26 '18 22:11 JulianKingman

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];

psousa avatar Nov 27 '18 11:11 psousa

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

JulianKingman avatar Dec 01 '18 03:12 JulianKingman

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
  });

thegamenicorus avatar Jan 23 '19 19:01 thegamenicorus

@thegamenicorus that's awesome!

psousa avatar Feb 14 '19 11:02 psousa