Hi all,
I am facing a problem following the code in the "Meet the Screen Time API" video. I've tried scheduling the monitoring time from 00:00 to 25:59 or some other time but functions in DeviceActivityMonitor are never being called.
I tried to print log from those functions, nothing shown. Is there any settings I've missed? In addition, I already changed the NSExtensionPrincipalClass value to my class name.
Any help would be appreciated!
-
—
g0mi
Add a CommentUpdate with code.
I have added the following code
extension DeviceActivityName{ static let daily = Self("daily") }Run the following line after authorization `let schedule = DeviceActivitySchedule( intervalStart: DateComponents(hour: 0, minute: 0), intervalEnd: DateComponents(hour: 23, minute: 59), repeats: true ) let center = DeviceActivityCenter()
do{ try center.startMonitoring(.daily, during: schedule) } catch { print("error: (error)") }`
And In My Class overriding DeviceActivityMonitor:
override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) let applicationTokens = model.selectionToDiscourage.applicationTokens let categoryTokens = model.selectionToDiscourage.categoryTokens model.store.shield.applications = applicationTokens.isEmpty ? nil : applicationTokens model.store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.specific(categoryTokens) }where model is my model class for storing the selections