Hi,
Problem: Even after successful schedule creation I am not getting call backs(intervalDidStart, intervalDidEnd) to my extension
I have created DeviceActivityMonitor extension by creating call Directory Extension and updated info plist with the value (com.apple.deviceactivity.monitor-extension) and updated principal class value too.
I try running the extension on my demo app which has the below code,
let schedule = DeviceActivitySchedule(
intervalStart: DateComponents(hour: 10, minute: 30),
intervalEnd: DateComponents(hour: 12, minute: 15),
repeats: true,
warningTime: nil)
do {
let center = DeviceActivityCenter()
center.stopMonitoring([.daily])
try center.startMonitoring(.daily, during: schedule)
print("Schedule created")
print(center.activities)
} catch {
print(error)
}
}
My extension has the below code,
override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
print("Entered Did Start")
}
override func intervalDidEnd(for activity: DeviceActivityName) {
super.intervalDidEnd(for: activity)
print("Entered Did End")
}
Please guide me to find out the issue. Thanks in advance.
Hi,
One of my friend suggested to debug extension process and check console which helped. I received the call back to the code and while observing console logs expected events fired for start and end. But I am not sure why print statement doesn't print any from extension principal class file.
Console logs under the process 'DeviceActivityMonitorExtension' below,
Interval started for daily
Interval ended for daily
Hope this will help.