Watching some of the historical WWDC videos about HealthKit would be a great start.
Some key classes are: HKSampleQuery
HKStatisticsCollectionQuery
HKAnchoredObjectQuery
HKSampleTypeIdentifier.stepCount, etc.
Regarding accessing the data without the user interacting with the app, you'd have to look into background delivery on the HKHealthStore class here - https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery
Make sure the user knows that you're doing this :)
Topic:
App & System Services
SubTopic:
General
Tags: