some additional information:
I tried to add a warning to happen 10 minutes after the start time as well:
guard let endDate = Calendar.current.date(byAdding: .minute, value: minutes, to: startDate),
let warningDate = Calendar.current.date(byAdding: .minute, value: 10, to: startDate) else {
return "Failed to create end date?"
}
let warningComponents = Calendar.current.dateComponents([.era, .year, .month, .day, .hour, .minute, .second], from: warningDate)
// Create schedule
let schedule = DeviceActivitySchedule(
intervalStart: startComponents,
intervalEnd: endComponents,
repeats: false,
warningTime: warningComponents
)
I have the intervalWillEndWarning method in my DeviceActivityMonitorExtension class schedule a local notification and found that it gets triggered immediately after the intervalDidStart method gets triggered. Again, intervalDidEnd never gets called.
However, if I manually call center.stopMonitoring() for my session, I get the intervalDidEnd notification.
It looks like my schedule is not getting used properly but I'm not sure why..
Post
Replies
Boosts
Views
Activity
The copyright trick did it! Thank you so much!