The data displayed about a child’s apps can be outdated (DeviceActivityReport), leading to misinformation for the user. When I access the “Screen Time” section (for child in the parent device) in the iPhone settings, I see there is an update functionality to force load the actual data.
I have tried various workarounds, such as attempting to force an update on the child’s device to call DeviceActivityReport and opening system settings, but none of these have been successful :(
How can I implement something similar? Is there a way to force update this data ?
Post
Replies
Boosts
Views
Activity
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.
I want to create an app to control a child's device. As I understand it, I need to follow this logic:
I have one app for both the child and the parent.
For the child, I request authorization with the following code:
try await AuthorizationCenter.shared.requestAuthorization(for: .child)
For the parent, I show functions like:
familyActivityPicker
Are these settings automatically applied to the child's device, or do I need to send a silent push notification to apply the new settings? Additionally, how can I get statistics from the child's device to the parent's device?