react-native-fitness
react-native-fitness copied to clipboard
Feature request - Option to filter manually entered data
Hi and thanks for this neat package!
I'm submitting a feature request for the possibility to left out user entered data when querying for distance/steps. This would enable to use only "real" data.
As a test, I managed to implement it in the iOs version of GetSteps by doing the following:
- Declare a predicate that leaves out User Entered data
NSPredicate *sourcePredicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];
- Use this predicate when querying:
HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:type quantitySamplePredicate:nil options:HKStatisticsOptionCumulativeSum anchorDate:anchorDate intervalComponents:interval];
I'd like to work on that feature request, but I do not master Swift nor Java and haven't experienced working on a bridge between RN and Native. I'm more than happy to help you, let me know how I could proceed!
Cheers
Any news on this? Would be great to filter manually entered data!
Hi and thanks for this neat package!
I'm submitting a feature request for the possibility to left out user entered data when querying for distance/steps. This would enable to use only "real" data.
As a test, I managed to implement it in the iOs version of GetSteps by doing the following:
- Declare a predicate that leaves out User Entered data
NSPredicate *sourcePredicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];
- Use this predicate when querying:
HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:type quantitySamplePredicate:nil options:HKStatisticsOptionCumulativeSum anchorDate:anchorDate intervalComponents:interval];
I'd like to work on that feature request, but I do not master Swift nor Java and haven't experienced working on a bridge between RN and Native. I'm more than happy to help you, let me know how I could proceed!
Cheers
this seems to work, still needs testing.
Perhaps there is a solution for android also In Manager.java there are processSteps and processDistances methods
if (!"user_input".equals(dp.getOriginalDataSource().getStreamName())) {
caloryMap.putString("startDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
caloryMap.putString("endDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
caloryMap.putDouble("quantity", dp.getValue(field).asFloat());
map.pushMap(caloryMap);
}
This if might solve it
Hi, It seems like someone has already made a fork that does the 'exclude user entered data' on both the android and iOS side: https://github.com/LVGP2021/react-native-fitness
It seems like this should be exposed as an option when querying (IE: either 'get all steps' or 'get not-manually-entered-steps) rather than it being 'hard ignored' all the time.
Is this project still active? If so I might refactor that code to make it an option and then do an MR in :)
Hi @IsaacInsoll , thanks foor your reply. Feel free to open a PR, any help will be appreciated