Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Summary of issues encountered with the Screen Time interface

I have developed three apps using the Screen Time API. The following are common problems I encountered in the three apps:

  1. DeviceActivityMonitorExtension is automatically killed after running for a few days (frequently)
  2. The same DeviceActivityEvent in DeviceActivityMonitorExtension is triggered twice during eventDidReachThreshold (especially obvious in iOS18.5)
  3. Screen Time authorization is automatically canceled for no reason (occasionally)

I hope to get help

After repeated testing, on the iOS 18.5 version, the listening event will be triggered even if the threshold is not reached.


private func buildEvents(with tokens: Set<ApplicationToken>, prefix: String) -> [DeviceActivityEvent.Name: DeviceActivityEvent] {
    var events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [:]
    for index in 0..<30 {
        // Set time threshold: first 29 events every 2 minutes, last event in 1 hour
        let threshold = (index == 29)
        ? DateComponents(hour: 1)
        : DateComponents(minute: (index + 1) * 2)
        let name = DeviceActivityEvent.Name("\(prefix)|\(index)")
        if #available(iOS 17.4, *) {
            events[name] = DeviceActivityEvent(
                applications: tokens,
                threshold: threshold,
                includesPastActivity: false
            )
        }else {
            events[name] = DeviceActivityEvent(
                applications: tokens,
                threshold: threshold
            )
        }
    }
    return events
}

This is my DeviceActivityEvent generation code. I hope the app is used to remind me every two minutes.

I found that the same event was triggered twice.

I experimented with other apps and my own app and found that the eventDidReachThreshold method is automatically triggered under the iOS 18.5 system version.

Summary of issues encountered with the Screen Time interface
 
 
Q