HELP ScreenTime API DeviceAcivityReport continious issues

Hi everyone,

I've been spending my evenings on the app for around 6 months that's using Screen Time API introduced in WWDC 21 (https://developer.apple.com/videos/play/wwdc2021/10123/), I'm having many issues with this API and looking for anyone who has experience with this API, I will appreciate any help or advice I can get!

I'm using DeviceActivityReport to display the dashboard with screen time usage and certain metrics. Device activity report extension runs in an isolated sandbox, which makes it harder to debug and can't make any network call or write to any storage, for privacy purposes which makes sense, but makes it very hard for development.

The issue is that the process where DeviceActivityReport is running crashes for no reason frequently or doesn't run at all. The API itself has many bugs, which is backed up by my experience, Opal app developers and Screen Time even made the news with its bugs. I see the same behaviour with other apps like Opal, but they can workaround somehow it and reload the report.

I'm experienced with UIKit but have little experience with SwiftUI, since ScreenTime API is using SwiftUI only I have to embed DeviceActivityReport in UIKit using UIHostingController and then inside of the device activity report extension target I'm using UIViewControllerRepresentable to embed UIKit into SwiftUI. But I've done some testing and the behaviour is the same when using pure SwiftUI, although there might be fewer hiccups, I couldn't rewrite the whole app.

That's the gist, there's too much code to include, but I can drop more code snippets if there's anyone who has experience with this API who can help me.

In the same boat as yours, please let me know if you find any solution to get data out of extension and use it in main app.

@pravinu that's 100% impossible because Device Activity Report Extension is in the sandbox that can read data but can't write to any storage or make any network calls

"To protect the user’s privacy, your extension runs in a sandbox. This sandbox prevents your extension from making network requests or moving sensitive content outside the extension’s address space" https://developer.apple.com/documentation/deviceactivity/deviceactivityreport

HELP ScreenTime API DeviceAcivityReport continious issues
 
 
Q