Ignore manual entries from Apple Health as a data source

Hi, I'm writing a fitness app that gets its data from the Apple App Store app.

So far so good.

Problem: In the Health application, you can manually enter data, which allows you to cheat.

Question: how can I exclude or ignore these specific data records.

Just data from "Source: Health", so I have the ability to read data from a random tracker.

+6
source share
1 answer

Manual HealthKit samples entered by the user will be set to YES for the HKMetadataKeyWasUserEntered metadata HKMetadataKeyWasUserEntered . To create a predicate that matches only patterns that were not entered, you can use the following:

 [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered]; 

Note that this should be stated as value != YES , because the value for the key can be YES, NO, or nil, and nil means NO.

+11
source

All Articles