Differentiating and Displaying Screen Time Data for Individual Children in App

Hi everyone,

I’m developing a parental control app using Apple's ScreenTime API, and I need to display ScreenTime data separately for each child in a family. The API offers options like .children and .all, but I’m looking for the best way to reliably filter and show data for a single child within the app.

I’ve seen other apps like Ohana successfully implement this feature, even the apple official family screen time feature has this where parents can view ScreenTime data for each child individually. I want to achieve a similar experience in my app, ensuring that if a parent selects "John," the app only displays John's ScreenTime, without mixing in data from his siblings.

Here’s the approach I’m considering using DeviceActivityFilter and DeviceActivityReport to target data for a specific child:

let filter = DeviceActivityFilter(
    segment: .children,
    intervals: .everyDay
)

let report = DeviceActivityReport(
    filter: filter
) { (data) in
    // Process and separate data for each child
    if let activityData = data as? DeviceActivityReportData {
        for child in activityData.children {
            if child.name == "ChildName" { // Replace "ChildName" with the actual child's name or identifier
                // Access and display data for the specific child
                print("Child: \(child.name), Screen Time: \(child.screenTime)")
            }
        }
    }
}

Context:

  • Goal: I need to ensure parents can view ScreenTime data for each child individually, similar to how Ohana does it. For example, selecting "John" should display only John's ScreenTime.
  • Challenge: While some data can be grouped within the DeviceActivity extension, I'm not entirely sure if this approach with DeviceActivityFilter is the most reliable way to isolate and display data for a single child.

Has anyone implemented a similar solution? Are there any alternative methods or best practices that could improve the accuracy and reliability of this filtering?

Any advice or examples would be greatly appreciated!

Thanks!

Hi,

Where are you getting the "childName"?

Also DeviceActivityData uses name components to parse names.

These are also optional so you will want to unwrap them first.

Rico

WWDR - DTS - Software Engineer

Hi Rico

Currently, we're considering asking parents to input either their child’s iOS name or Apple ID to identify each child, but this is just one option we're exploring.

We have already parsed the name from DeviceActivityData, so we can filter based on that i think not sure how. Our primary goal is to find a reliable way to filter and display individual children's ScreenTime data, similar to how Apple’s ScreenTime feature shows separate reports for each child.

Given that Apple’s implementation successfully differentiates and displays individual ScreenTime reports, we’re looking for guidance on how to achieve this using the ScreenTime API. Any suggestions or best practices for filtering data for individual children would be greatly appreciated.

@Engineer @rico Any help with this that you know of?

Differentiating and Displaying Screen Time Data for Individual Children in App
 
 
Q