Detect if HealthKit activity has been entered manually

谁说我不能喝 提交于 2019-12-21 17:44:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!