问题
You can check which app inserted the activity via the 'source' activity. Is there a way to know if the activity has been entered manually or if the activity was an activity that was recorded live from sensors and added to HealthKit?
回答1:
Apple only provides two properties for the HKSource
class, the bundleIdentifier
and the name
of the source, as of iOS8.x
The bundle identifier of the entry if made manually will be com.apple.Health, which is the bundle identifier of the Health app. Notice the capital H. When you pull your data just ignore the data which has a bundle identifier of com.apple.Health.
That way you will be only considering activities which are not manual.
Hope this helps. Let me know if you need more information.
You can also refer the link here for another way to do this: Ignore manual entries from Apple Health app as Data Source
来源:https://stackoverflow.com/questions/32147812/detect-if-healthkit-activity-has-been-entered-manually