Post

Replies

Boosts

Views

Activity

Reply to Device Activity Extension not being called
Update 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
Topic: App & System Services SubTopic: General Tags:
May ’22
Reply to Device Activity Extension not being called
I finally figured it out. The apps being monitored were not changing with my model selection. I had to call center.startMonitoring() after performing the selection. Also, I couldn't print logs from the extension. However, I could perform other actions like showing a notification to verify it worked.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to Device Activity Extension not being called
Update 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
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
May ’22