DeviceActivityReport
presents statistics for a device: https://developer.apple.com/documentation/deviceactivity/deviceactivityreport
The problem: DeviceActivityReport
can present statistics with a delay for a parent device (when DeviceActivityReport
is presenting, the DeviceActivityReportExtension
is called to process the statistics). One possible solution is to call DeviceActivityReport
periodically throughout the day in a child device. However, the app will not be available all day. Is there any way to run DeviceActivityReport
in the background?
I have tried the following approach, but it didn’t work (DeviceActivityReportExtension
didnt call):
let hostingController: UIHostingController? = .init(rootView: DeviceActivityReport(context, filter: filter)) hostingController?.view.frame = .init(origin: .zero, size: .init(width: 100, height: 100)) hostingController?.beginAppearanceTransition(true, animated: false) hostingController?.loadView() hostingController?.viewDidLoad() try? await Task.sleep(for: .seconds(0.5)) hostingController?.viewWillAppear(true) hostingController?.viewWillLayoutSubviews() try? await Task.sleep(for: .seconds(0.5)) hostingController?.viewDidAppear(true) try? await Task.sleep(for: .seconds(0.5)) hostingController?.didMove(toParent: rootVC) try? await Task.sleep(for: .seconds(0.5)) hostingController?.viewWillLayoutSubviews() hostingController?.viewDidLayoutSubviews() hostingController?.view.layoutIfNeeded() hostingController?.view.layoutSubviews() hostingController?.endAppearanceTransition()
Is there any way to run DeviceActivityReport in the background? (when app is not visible/closed). The main problem is call DeviceActivityReport