DeviceActivity -> Screen time API. Accessing struct information

I need to get the time of phone pickup and time of usage after the pickup and drop.

DeviceActivityData.ActivitySegment -> a struct contains all these information.

Where and how can i access these information?

   let v = DeviceActivityData.ActivitySegment().totalActivityDuration ERROR: 'DeviceActivityData.ActivitySegment' cannot be constructed because it has no accessible initializers

How do I initialise DeviceActivityData?

The DeviceActivityData.ActivitySegment type is provided only to Device Activity report extensions and cannot be instantiated by clients. You must implement a Device Activity report extension that conforms to the DeviceActivityReportExtension protocol. In order to create a new extension, click File > New > Target... > iOS > Device Activity Report Extension in Xcode. Your app can then create and display a DeviceActivityReport. The UI for this view will be rendered by your extension and the system will provide the chosen DeviceActivityReportScene with data via the scene's makeConfiguration function.

Thanks,

I have created a new target named "Report" (File > New > Target... > iOS > Device Activity Report Extension ) I am getting this error while trying to view the "TotalActivityView" from the extension:

UnknownAppExtensionError: "Report.appex" is an unsupported extension

Previews cannot be hosted in the app extension "Report.appex"

productType: com.apple.product-type.extensionkit-extension

DeviceActivity -> Screen time API. Accessing struct information
 
 
Q