Search results for

“DeviceActivityMonitor”

143 results found

Post

Replies

Boosts

Views

Activity

Reply to Screen Time discrepancy between DeviceActivityMonitor and DeviceActivityReport
Thank you for your reply, and for all your replies on my questions on the DeviceActivity Framework! I've filed https://feedbackassistant.apple.com/feedback/11901286. But do you have any information about apps or websites that do not fall under a specific category, but are still monitored by DeviceActivityMonitor by default (without selecting any categories, apps, or websites). I am particularly suspicious of FaceTime, which does not show up anywhere in a breakdown inside iOS' native Screen Time app, but does add to total Screen Time reported. Settings and Safari also appear to have non-typical behavior like this. Can you provide any knowledge you have about these apps that do not appear under a specific category, and how they behave under the DeviceActivity Framework?
Topic: Privacy & Security SubTopic: General Tags:
Dec ’22
Reply to Best way to pause DeviceActivitySchedule
I finally found a suitable solution, though it may not be the best approach. I'm storing the selection in shared UserDefaults with the Schedule ID as the key. This way, I can always retrieve the selected apps when I have the Schedule ID. This solved the problem of not having access to the apps that should be restricted. The other issue is actually pausing the monitoring, for which this solution is quite elegant: When the pausing action starts, all restrictions for this activity should be cleared, and the activity should no longer be monitored. Start a new activity with the identifier pause+(oldID) using the same selection and schedule times. The new schedule should contain a proper warningTime. Learn more about it here (it's not as simple as you might think): Apple Developer Documentation. In your DeviceActivityMonitor, your intervalDidStart(for activity:) function will now be called. But since the new schedule is started with the ID pause+(oldID), you can react to the name of the activity. You can n
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’24
Reply to iOS 26 regression: `DeviceActivityEvent`: `eventDidReachThreshold` called immediately (instead of waiting till threshold is reached)
[quote='889277022, ohadh123, /thread/808470?answerId=889277022#889277022, /profile/ohadh123'] Just checking in again - you facing the issue on iOS 26.5? [/quote] Hey @ohadh123 and hey @DTS Engineer Albert! Unfortunately, we are still seeing this issue reproduce on iOS 26.5. From my feeling it became slightly better, but now that 26.5 is rolling out to all users it’s clear that this is still a major issue. We are tracking events in our analytics of DeviceActivityMonitor thresholds immediately firing after scheduling the monitor. And even though iOS 26.5 was just released publicly, the reports are steadily growing and firing a couple hundred times per day. I have updated my feedback accordingly and also assigned a fresh sysdiagnose from my own device where I also reproduce the issue: FB18061981 Hope that helps in getting this resolved finally!
3d
Reply to Issues in rendering DeviceActivityController
I can't get anything to print in the functions of my class with the override functions for DeviceActivityMonitor How are you printing in those functions? If you are just using the print function in your extension, those messages will not appear in Xcode's console while you are running your app (this is because your extension is a different process than your app). In order to verify whether or not your extension is logging things, use OSLog and look for your extension's logging in the Console app on your Mac (rather than Xcode's built-in console). I can't get a rendering of a device manager - even when am just sending 0m as a string from the TotalActivityReport's makeConfiguration function without touching the data given. Apologies, but I'm not sure I understand the issue. If you discover problems with the DeviceActivity report APIs, please file a bug report using Feedback Assistant and attach a sample app that reproduces the issue. Thanks in advance!
Topic: App & System Services SubTopic: General Tags:
Feb ’23
How to designate principal class
I am building an app that uses DeviceActivity framework. Looking at the documentation, I need to subclass (https://developer.apple.com/documentation/deviceactivity/deviceactivitymonitor), I need to subclass DeviceActivityMonitor and designate the subclass as the principal class of my app extension. I am wondering how to designate my subclass as the principal class. (I am new to iOS development :) .
2
0
1.1k
Aug ’21
Reply to Extract raw Screen Time data? Security says it's 'expected'
Hi, thanks for posting this — I've been hitting the exact same wall. I'm building a screen time management app and spent considerable time trying to persist per-app usage data from the DeviceActivityReportExtension to the App Group container. I exhaustively tested every storage mechanism available: Core Data, JSON files, UserDefaults (App Group suite), Keychain, raw POSIX syscalls, SQLite, iCloud KV, and NSUbiquitousKeyValueStore. All fail with permission errors — the extension is completely write-locked at the kernel level (POSIX errno 1 / EPERM). I also confirmed the DeviceActivityMonitor extension has the same restriction. So I'm very interested in your finding that the host app can reconstruct raw activity data from the report. Could you share more about the technique you used? Specifically: How does your host app access the data from the report extension? Is it through the rendered view hierarchy, some callback mechanism, or something else entirely? Are you able to get per-app bundle identifiers
Topic: App & System Services SubTopic: General Tags:
Feb ’26
Reply to Is the Screen Time API completely broken in the betas?
FamilyActivityPicker does not list installed apps on either of the guardian's or child's devices, it only lists the categories. It's not clear at this point whether FamilyActivityPicker needs to be called on the parent or the child device. The apps are now shown in the app running on the child device. They are not shown on the parent device. After successfully authorizing a child device via AuthorizationCenter.shared.requestAuthorization, DeviceActivityCenter.startMonitoring always results in an MonitoringError.unauthorized error. This appears to have been fixed. Even though an app is authorized to managed ScreenTime on a child device, the child can always just delete the app. This is fixed, parental sign-in is now required to delete the app. The DeviceActivityMonitor extension is launched at the start of the interval, so that's good as well. But there's still the critical issue where the parent app cannot list and set restricted apps installed on the child device. I'm still wondering whether the par
Topic: App & System Services SubTopic: General Tags:
Jul ’21
Reply to Schedule Task (Screen Time API) on iOS in background mode
Fixed by recreating Target Extension & changing from print log to show from local notification, somehow Print log from the target extension is not showing on XCode even though I already do Debug > Attach to the Process // // DeviceActivityMonitorExtension.swift // NewMonitor // // Created by Mochammad Yusuf Fachroni on 18/08/23. // import DeviceActivity import UserNotifications import ManagedSettings // Optionally override any of the functions below. // Make sure that your class name matches the NSExtensionPrincipalClass in your Info.plist. class DeviceActivityMonitorExtension: DeviceActivityMonitor { func showLocalNotification(title: String, desc: String) { let content = UNMutableNotificationContent() content.title = title content.body = desc content.sound = .default let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) let request = UNNotificationRequest(identifier: localNotification, content: content, trigger: trigger) UNUserNotificationCenter.current().add(reques
Topic: App & System Services SubTopic: General Tags:
Aug ’23
Reply to Lock device, Restrict all apps | Screen Time API | iOS 16
Locking and unlocking the device is not possible via the Screen Time API. If you'd like to see that capability in a future release, please file a report via Feedback Assistant. You cannot restrict all apps on the device, but you can shield all app and websites by setting both store.shield.applicationCategories and store.shield.webDomainCategories to the .all() ActivityCategoryPolicy. You can also block all webContent by setting webContent.blockedByFilter to the .all() WebContentSettings.FilterPolicy. See the ShieldSettings and WebContentSettings documentation for more information. Yes you can create schedules via the Device Activity API. Here's a quick example on how to naively implement a schedule that shields all apps and websites for the weekend: In the App: extension DeviceActivityName { static let weekend = Self(weekend) } let weekendSchedule = DeviceActivitySchedule( intervalStart: DateComponents(calendar: calendar, hour: 0, minute: 0, weekday: 7), intervalEnd: DateComponents(calendar: calendar, hour: 2
Topic: App & System Services SubTopic: General Tags:
Oct ’22
FamilyControls Entitlement Not Working for External TestFlight Testers
Hi all, I’ve run into a frustrating issue with the FamilyControls and DeviceActivityMonitor APIs. I’ve received official approval from Apple to use the com.apple.developer.family-controls entitlement (distribution), and I’ve added the entitlement to both my main app and the DeviceActivityMonitor extension. I’ve also ensured the correct App Group is configured for both targets. Everything works perfectly when I install the app on my own device as an internal TestFlight tester. App blocking works, the DeviceActivityMonitor extension runs as expected, and the apps selected by the user are correctly shielded. However, for external TestFlight testers, while they do receive the Screen Time permission prompt, and can select apps to block, nothing actually gets blocked. It appears that the DeviceActivityMonitor extension is not being triggered at all on their devices. I’ve verified the following: The entitlement is approved and visible in App Store Connect The build is approved for
2
0
186
Apr ’25
Reply to The DeviceActivityMonitor did not trigger a callback
Below is all the code; the method intervalDidStart has never been called. Can you help me? import UIKit import MobileCoreServices import ManagedSettings import DeviceActivity class MyMonitor: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) print(interval did start) let model = MyModel.shared let applications = model.selectionToDiscourage.applicationTokens store.shield.applications = applications.isEmpty ? nil : applications store.appStore.maximumRating = 200 } override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) store.shield.applications = nil store.clearAllSettings() } } // // MyModel.swift // FamilyCotrol // // Created by mac on 2024/6/24. // import UIKit import Foundation import FamilyControls import DeviceActivity import ManagedSettings class MyModel: ObservableObject { static let shared = MyModel() let store = ManagedSettingsStore() p
Topic: App & System Services SubTopic: General Tags:
Jun ’24
App Shielding unexpectedly active outside of schedule
I'm using the Screen Time API to shield apps the user selects. The problem is, that the apps are always shielded, even outside of the schedule. Here is my function initiateMonitoring: func initiateMonitoring(scheduleStart: DateComponents, scheduleEnd: DateComponents) { let schedule = DeviceActivitySchedule( intervalStart: scheduleStart, intervalEnd: scheduleEnd, repeats: true ) let center = DeviceActivityCenter() do { try center.startMonitoring(.daily, during: schedule) logger.log(STARTED MONITORING) } catch { logger.log(FAILED MONITORING: (error.localizedDescription)) } } The expected result should be that the selected Apps should be blocked during the schedule the user specified, but not outside the schedule, but it is blocked 24/7. I've experimented with the DateComponents, but the issue may be somewhere else. What's maybe interesting is, I tried Logging the DeviceActivityMonitor and somehow it doesn't get called. The logging-output from initiateMonitoring is printed in the console, but for the DeviceActivityMonitor
1
0
859
Mar ’24
Irrecoverable Crash in Extension
We are seeing cases where DeviceActivityMonitoring extension is crashing permanently. This is due to a now-fixed bug that was causing a stack overflow. On devices where the extension crashed, it appears permanently unable to recover - even weeks after the crash and after multiple restarts of the device. It looks like recovery is being attempted, as the same four NSLog activities are emitted roughly every second that the phone is active. Logs: Process: DeviceActivityMonitoring Activity: beginning extension request Message: NSExtensionPrincipalClass `` does not conform to NSExtensionRequestHandling protocol! Process: DeviceActivityMonitoring Activity: Loading Preferences From User Session CFPrefsD Message: Process: DeviceActivityMonitoring Activity: container_system_group_path_for_identifier Message: Requesting container lookup; class = 13, identifier = , group_identifier = , create = 1, temp = 0, euid = 501, uid = 501 container_query_get_single_result: success container_syst
1
0
1k
Aug ’23
Reply to Screen Time discrepancy between DeviceActivityMonitor and DeviceActivityReport
Thank you for your reply, and for all your replies on my questions on the DeviceActivity Framework! I've filed https://feedbackassistant.apple.com/feedback/11901286. But do you have any information about apps or websites that do not fall under a specific category, but are still monitored by DeviceActivityMonitor by default (without selecting any categories, apps, or websites). I am particularly suspicious of FaceTime, which does not show up anywhere in a breakdown inside iOS' native Screen Time app, but does add to total Screen Time reported. Settings and Safari also appear to have non-typical behavior like this. Can you provide any knowledge you have about these apps that do not appear under a specific category, and how they behave under the DeviceActivity Framework?
Topic: Privacy & Security SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Best way to pause DeviceActivitySchedule
I finally found a suitable solution, though it may not be the best approach. I'm storing the selection in shared UserDefaults with the Schedule ID as the key. This way, I can always retrieve the selected apps when I have the Schedule ID. This solved the problem of not having access to the apps that should be restricted. The other issue is actually pausing the monitoring, for which this solution is quite elegant: When the pausing action starts, all restrictions for this activity should be cleared, and the activity should no longer be monitored. Start a new activity with the identifier pause+(oldID) using the same selection and schedule times. The new schedule should contain a proper warningTime. Learn more about it here (it's not as simple as you might think): Apple Developer Documentation. In your DeviceActivityMonitor, your intervalDidStart(for activity:) function will now be called. But since the new schedule is started with the ID pause+(oldID), you can react to the name of the activity. You can n
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’24
Reply to iOS 26 regression: `DeviceActivityEvent`: `eventDidReachThreshold` called immediately (instead of waiting till threshold is reached)
[quote='889277022, ohadh123, /thread/808470?answerId=889277022#889277022, /profile/ohadh123'] Just checking in again - you facing the issue on iOS 26.5? [/quote] Hey @ohadh123 and hey @DTS Engineer Albert! Unfortunately, we are still seeing this issue reproduce on iOS 26.5. From my feeling it became slightly better, but now that 26.5 is rolling out to all users it’s clear that this is still a major issue. We are tracking events in our analytics of DeviceActivityMonitor thresholds immediately firing after scheduling the monitor. And even though iOS 26.5 was just released publicly, the reports are steadily growing and firing a couple hundred times per day. I have updated my feedback accordingly and also assigned a fresh sysdiagnose from my own device where I also reproduce the issue: FB18061981 Hope that helps in getting this resolved finally!
Replies
Boosts
Views
Activity
3d
Reply to Issues in rendering DeviceActivityController
I can't get anything to print in the functions of my class with the override functions for DeviceActivityMonitor How are you printing in those functions? If you are just using the print function in your extension, those messages will not appear in Xcode's console while you are running your app (this is because your extension is a different process than your app). In order to verify whether or not your extension is logging things, use OSLog and look for your extension's logging in the Console app on your Mac (rather than Xcode's built-in console). I can't get a rendering of a device manager - even when am just sending 0m as a string from the TotalActivityReport's makeConfiguration function without touching the data given. Apologies, but I'm not sure I understand the issue. If you discover problems with the DeviceActivity report APIs, please file a bug report using Feedback Assistant and attach a sample app that reproduces the issue. Thanks in advance!
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’23
Designate principal class
Hello, I am wondering how to designate my DeviceActivityMonitor extension as the principal class on Xcode 13 beta 5 Documentation: https://developer.apple.com/documentation/deviceactivity/deviceactivitymonitor
Replies
1
Boosts
0
Views
3.3k
Activity
Aug ’21
How to designate principal class
I am building an app that uses DeviceActivity framework. Looking at the documentation, I need to subclass (https://developer.apple.com/documentation/deviceactivity/deviceactivitymonitor), I need to subclass DeviceActivityMonitor and designate the subclass as the principal class of my app extension. I am wondering how to designate my subclass as the principal class. (I am new to iOS development :) .
Replies
2
Boosts
0
Views
1.1k
Activity
Aug ’21
Reply to Extract raw Screen Time data? Security says it's 'expected'
Hi, thanks for posting this — I've been hitting the exact same wall. I'm building a screen time management app and spent considerable time trying to persist per-app usage data from the DeviceActivityReportExtension to the App Group container. I exhaustively tested every storage mechanism available: Core Data, JSON files, UserDefaults (App Group suite), Keychain, raw POSIX syscalls, SQLite, iCloud KV, and NSUbiquitousKeyValueStore. All fail with permission errors — the extension is completely write-locked at the kernel level (POSIX errno 1 / EPERM). I also confirmed the DeviceActivityMonitor extension has the same restriction. So I'm very interested in your finding that the host app can reconstruct raw activity data from the report. Could you share more about the technique you used? Specifically: How does your host app access the data from the report extension? Is it through the rendered view hierarchy, some callback mechanism, or something else entirely? Are you able to get per-app bundle identifiers
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’26
Reply to Is the Screen Time API completely broken in the betas?
FamilyActivityPicker does not list installed apps on either of the guardian's or child's devices, it only lists the categories. It's not clear at this point whether FamilyActivityPicker needs to be called on the parent or the child device. The apps are now shown in the app running on the child device. They are not shown on the parent device. After successfully authorizing a child device via AuthorizationCenter.shared.requestAuthorization, DeviceActivityCenter.startMonitoring always results in an MonitoringError.unauthorized error. This appears to have been fixed. Even though an app is authorized to managed ScreenTime on a child device, the child can always just delete the app. This is fixed, parental sign-in is now required to delete the app. The DeviceActivityMonitor extension is launched at the start of the interval, so that's good as well. But there's still the critical issue where the parent app cannot list and set restricted apps installed on the child device. I'm still wondering whether the par
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Schedule Task (Screen Time API) on iOS in background mode
Fixed by recreating Target Extension & changing from print log to show from local notification, somehow Print log from the target extension is not showing on XCode even though I already do Debug > Attach to the Process // // DeviceActivityMonitorExtension.swift // NewMonitor // // Created by Mochammad Yusuf Fachroni on 18/08/23. // import DeviceActivity import UserNotifications import ManagedSettings // Optionally override any of the functions below. // Make sure that your class name matches the NSExtensionPrincipalClass in your Info.plist. class DeviceActivityMonitorExtension: DeviceActivityMonitor { func showLocalNotification(title: String, desc: String) { let content = UNMutableNotificationContent() content.title = title content.body = desc content.sound = .default let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) let request = UNNotificationRequest(identifier: localNotification, content: content, trigger: trigger) UNUserNotificationCenter.current().add(reques
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Lock device, Restrict all apps | Screen Time API | iOS 16
Locking and unlocking the device is not possible via the Screen Time API. If you'd like to see that capability in a future release, please file a report via Feedback Assistant. You cannot restrict all apps on the device, but you can shield all app and websites by setting both store.shield.applicationCategories and store.shield.webDomainCategories to the .all() ActivityCategoryPolicy. You can also block all webContent by setting webContent.blockedByFilter to the .all() WebContentSettings.FilterPolicy. See the ShieldSettings and WebContentSettings documentation for more information. Yes you can create schedules via the Device Activity API. Here's a quick example on how to naively implement a schedule that shields all apps and websites for the weekend: In the App: extension DeviceActivityName { static let weekend = Self(weekend) } let weekendSchedule = DeviceActivitySchedule( intervalStart: DateComponents(calendar: calendar, hour: 0, minute: 0, weekday: 7), intervalEnd: DateComponents(calendar: calendar, hour: 2
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’22
FamilyControls Entitlement Not Working for External TestFlight Testers
Hi all, I’ve run into a frustrating issue with the FamilyControls and DeviceActivityMonitor APIs. I’ve received official approval from Apple to use the com.apple.developer.family-controls entitlement (distribution), and I’ve added the entitlement to both my main app and the DeviceActivityMonitor extension. I’ve also ensured the correct App Group is configured for both targets. Everything works perfectly when I install the app on my own device as an internal TestFlight tester. App blocking works, the DeviceActivityMonitor extension runs as expected, and the apps selected by the user are correctly shielded. However, for external TestFlight testers, while they do receive the Screen Time permission prompt, and can select apps to block, nothing actually gets blocked. It appears that the DeviceActivityMonitor extension is not being triggered at all on their devices. I’ve verified the following: The entitlement is approved and visible in App Store Connect The build is approved for
Replies
2
Boosts
0
Views
186
Activity
Apr ’25
Reply to The DeviceActivityMonitor did not trigger a callback
Below is all the code; the method intervalDidStart has never been called. Can you help me? import UIKit import MobileCoreServices import ManagedSettings import DeviceActivity class MyMonitor: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) print(interval did start) let model = MyModel.shared let applications = model.selectionToDiscourage.applicationTokens store.shield.applications = applications.isEmpty ? nil : applications store.appStore.maximumRating = 200 } override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) store.shield.applications = nil store.clearAllSettings() } } // // MyModel.swift // FamilyCotrol // // Created by mac on 2024/6/24. // import UIKit import Foundation import FamilyControls import DeviceActivity import ManagedSettings class MyModel: ObservableObject { static let shared = MyModel() let store = ManagedSettingsStore() p
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’24
Creating device activity monitor extension
I am writing an app of family controls and device settings. In the docs for DeviceActivityMonitor I read about the principal class of device activity monitor extension, so I have to implement it. But, in XCode there is no such extension. How do i create it?
Replies
3
Boosts
0
Views
3.2k
Activity
Jun ’21
App Shielding unexpectedly active outside of schedule
I'm using the Screen Time API to shield apps the user selects. The problem is, that the apps are always shielded, even outside of the schedule. Here is my function initiateMonitoring: func initiateMonitoring(scheduleStart: DateComponents, scheduleEnd: DateComponents) { let schedule = DeviceActivitySchedule( intervalStart: scheduleStart, intervalEnd: scheduleEnd, repeats: true ) let center = DeviceActivityCenter() do { try center.startMonitoring(.daily, during: schedule) logger.log(STARTED MONITORING) } catch { logger.log(FAILED MONITORING: (error.localizedDescription)) } } The expected result should be that the selected Apps should be blocked during the schedule the user specified, but not outside the schedule, but it is blocked 24/7. I've experimented with the DateComponents, but the issue may be somewhere else. What's maybe interesting is, I tried Logging the DeviceActivityMonitor and somehow it doesn't get called. The logging-output from initiateMonitoring is printed in the console, but for the DeviceActivityMonitor
Replies
1
Boosts
0
Views
859
Activity
Mar ’24
Irrecoverable Crash in Extension
We are seeing cases where DeviceActivityMonitoring extension is crashing permanently. This is due to a now-fixed bug that was causing a stack overflow. On devices where the extension crashed, it appears permanently unable to recover - even weeks after the crash and after multiple restarts of the device. It looks like recovery is being attempted, as the same four NSLog activities are emitted roughly every second that the phone is active. Logs: Process: DeviceActivityMonitoring Activity: beginning extension request Message: NSExtensionPrincipalClass `` does not conform to NSExtensionRequestHandling protocol! Process: DeviceActivityMonitoring Activity: Loading Preferences From User Session CFPrefsD Message: Process: DeviceActivityMonitoring Activity: container_system_group_path_for_identifier Message: Requesting container lookup; class = 13, identifier = , group_identifier = , create = 1, temp = 0, euid = 501, uid = 501 container_query_get_single_result: success container_syst
Replies
1
Boosts
0
Views
1k
Activity
Aug ’23