With your activityManager (CMMotionActivityManager instance in your Data Model) do a query when an app is restarted ref https://developer.apple.com/documentation/coremotion/cmmotionactivitymanager/1615929-queryactivitystarting HOWEVER, only the last 7 days of activity are available - and you'd need to know when the app was terminated or suspended so as not to double count. It might also be possible to schedule a batch background task (e.g. at night) to run the query and place results in permanent data storage. Check out this reference https://developer.apple.com/documentation/backgroundtasks/choosing_background_strategies_for_your_app particularly"Wake Your App with a Background Push". I've never done this, only knowing about it from the documentation.
Good luck and regards, Michaela
Topic:
App & System Services
SubTopic:
Hardware
Tags: