Combining Screen Time Usage with HealthKit Data in a Chart

Hello Apple Developer Community,

I’m working on creating a chart that combines Screen Time Usage data with Workout Time from HealthKit.

I’ve successfully implemented a DeviceActivityReportExtension to fetch Screen Time data and draw a chart. I’m also able to read HealthKit data from the main app.

However, I’m having trouble integrating the HealthKit data into the View generated by the DeviceActivityReportExtension. I’ve attempted to read HealthKit data directly from the extension , but this doesn’t seem to work, likely due to HealthKit access restrictions in extensions. I also tied using a shared object to pass HealthKit data to the extension, but unfortunately this didn’t seem to work as expected.

I’d greatly appreciate any suggestions on how to successfully integrate HealthKit data into the extension-generated View. Has anyone dealt with a similar challenge or found a workaround for this?

Thanks in advance for your help!

Combining Screen Time Usage with HealthKit Data in a Chart
 
 
Q