Hello! I am developing an app using the Screen Time API. Everything is good, but I have a problem with DeviceActivityReport. On the child’s device, stats are synced to the app in about 1-5 minutes. However, on the parent’s device, it can take around an hour or more. How can I make the stats sync faster between the child’s device and the parent’s device?
How I Implemented It
@Published var context: DeviceActivityReport.Context = .init("Time Limit") let filter = DeviceActivityFilter( segment: .daily( during: Calendar.current.dateInterval(of: .day, for: .now)! ), users: .children, devices: .all, applications: applicationTokens ) DeviceActivityReport(viewModel.context, filter: viewModel.filter) .frame(maxHeight: viewModel.maxReportHeight)
In the Report Extension (Test Code)
for await d in data { result += "device.name=\(d.device.name ?? "")" result += "\nuser.appleID=\(d.user.appleID ?? "")" result += "\ngivenName=\(d.user.nameComponents?.givenName ?? "")" result += "\nrole=\(d.user.role.rawValue)" for await activity in d.activitySegments { result += "\nactivitySegments hashValue=\(activity.hashValue)" result += "\ntotalActivityDuration=\(activity.totalActivityDuration)" result += "\ndateInterval=\(activity.dateInterval)" for await category in activity.categories { result += "\ncategory=\(category.category.localizedDisplayName ?? "")" for await app in category.applications { result += "\napp=\(app.application.bundleIdentifier ?? ""), time=\(app.totalActivityDuration)" } } } }
Problems:
activity.categories can be empty for a long time
app.totalActivityDuration contains outdated information
I need to wait about 1+ hours to get “actual” information.