DeviceActivityEvent with includesPastActivity = false, sometimes does not trigger callback

Sometimes when I schedule a DeviceActivityEvent with the includesPastActivity property set to false, the event is never triggered. I tried with thresholds of 20 seconds and 1 minute and both did not work.

I submitted feedback with more details FB15220094.

Is anyone else experiencing this issue ? or does anyone know about a fix ?

Hey, I'm experiencing similar issues with inconsistencies when includesPastActivity is false, the only (simple) solution I came up with was a version check, since then it works for above iOS 17.4 at least

func activityEvent(_ key: String, threshold: DateComponents? = nil) -> DeviceActivityEvent {
loadSelection(for: key)
let applications = selectionToRestrict
if #available(iOS 17.4, *) {
return DeviceActivityEvent(
applications: applications.applicationTokens,
categories: applications.categoryTokens,
webDomains: applications.webDomainTokens,
threshold: threshold ?? DateComponents(minute: 0),
includesPastActivity: true
)
} else {
return DeviceActivityEvent(
applications: applications.applicationTokens,
categories: applications.categoryTokens,
webDomains: applications.webDomainTokens,
threshold: threshold ?? DateComponents(minute: 0)
)
}
}

If you don't want to set it to true, I unfortunately cannot help you. This seems to be one of many issues with DeviceActivity.

DeviceActivityEvent with includesPastActivity = false, sometimes does not trigger callback
 
 
Q