Yesterdays tutorial was about the HKActivitySummaryQuery which allows your app to seek permission from the user to access the exercise ring, and all history and details associated with it. The query is one of the simplest available in HealthKit. The only parameter you can pass in is a predicate to specify a range of dates, or a single date. If you set it to nil, it will read all activity of the user.
In todays tutorial we will look at the long-running query that is available for HKActivitySummaryQuery. This particular version of the query keeps running in the background and monitors for changes. Each time the health store is updated with new data; either stand, exercise, or active calories; the update handler will be called which will allow you to refresh your views, should you need to.
As well as looking at the query, we will also add a UIView to the storyboard and set this up as a HKActivityRingView to display the rings on the view. [Read more…]