Search results for

DeviceActivityMonitor

127 results found

Post

Replies

Boosts

Views

Activity

DeviceActivityMonitor not working on development since I've had my Family Controls (Distribution) entitlement approved
I recently got approved for the Family Controls (Distribution) entitlement, and since then it seems that I cannot use the DeviceActivityMonitor extension on the dev environment anymore. I've tried attaching a debugger to the DeviceActivityMonitor process but it's never called so does not attach, and I can't see why it is not attaching. I've tried reverted back to old versions which I know definitely worked, and it's still not working... However, the DeviceActivityReport extension seems to be working fine. Any help or advice on how I can actually debug this would be greatly appreciated!
1
0
947
Aug ’23
DeviceActivityMonitor startMonitoring error
I created my Device Activity Monitor extension, and then attempted to start monitoring using the code example from the video: 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) } The startMonitoring call always fails for me with the same error: [monitor] Failed to create UsageTrackingAgent proxy: Error Domain=NSCocoaErrorDomain Code=4099 The connection to service on pid 0 named com.apple.UsageTrackingAgent was invalidated. UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.UsageTrackingAgent was invalidated.} Setting up the extension is a very manual process, so I likely missed a step somewhere, but any ideas on what this error might be indicating?
2
0
1.8k
Jul ’21
Analytics events not triggering with DeviceActivityMonitor app extension on iOS 17
I'm encountering a problem with the DeviceActivityMonitor framework on iOS 17 that wasn't present in iOS 16. The app extension sends analytics events via the Segment SDK whenever the extension's functions are called. This setup worked flawlessly on iOS 16. However, since upgrading to iOS 17, it appears that the vast majority of my iOS 17 users are not triggering the expected analytics events. I'm aware that network requests in app extensions are not officially supported, yet somehow, Segment's SDK managed to function without issues in the previous OS version. Could there have been any changes in iOS 17 related to app extensions or the DeviceActivityMonitor framework that might be influencing this change in analytics behavior? Or perhaps there's a new restriction or modification in the app extension's network capabilities that I might be overlooking? Any insights into these changes or guidance on how to ensure analytics events are triggered reliably within the app extension on iOS 17 would be
0
0
690
Nov ’23
[iOS 18 Beta 4] DeviceActivityMonitor extension is more likely to deadlock
Hi there, My app uses all the Screen Time API's with individual FamilyControls authorization. I've been using the API's for over 2 years (since they came out). In iOS 18 Beta (maybe started in Beta 3?), I've been experiencing random issues. I tracked it down to where it seems like DeviceActivityMonitor extension is more likely to deadlock in iOS 18. To reproduce: when DeviceActivityMonitorExtension.intervalDidEnd gets called, IF you call DeviceActivityCenter.startMonitoring for that SAME DeviceActivityName from the DeviceActivityMonitorExtension , the startMonitoring call deadlocks (if I pause debugger, it does not advance past DeviceActivityCenter.startMonitoring). The bug is reported in FB14664238. It also contains a sample project where you can reproduce this. I also note in the comment section that this is not the only way to encounter this problem. My application code (which is a lot more complicated) seems to deadlock on calling DeviceActivityCenter.activities. As a result, there seems to be an
1
0
841
Aug ’24
SCREEN TIME API is reporting false positives to DeviceActivityMonitor extension in iOS 26.2 & 26.3
Since the iOS 26.2 update, we have been experiencing anomalous behavior with the DeviceActivityMonitor extension when utilizing the ScreenTime API. Specifically, we are receiving the eventDidReachThreshold event within a few minutes of initiating monitoring, despite configuring a high usage limit. The process of turning off Screen Time -> restarting the device -> turning on Screen Time does not work. Any ideas? Thanks Filed Feedback Assistant: FB21560904
0
0
275
Jan ’26
DeviceActivityMonitor event threshold callbacks often triggered multiple times in a row
My app sends screen time awareness notifications based on DeviceActivityMonitor thresholds. Often, users receive two notifications in a row for the same screen time threshold. This means that the app extension is triggering the same eventDidReachThreshold callback function twice for the same threshold. I've made sure that there is only one activity schedule being monitored. This happens often, but not every time (over 50% of the time). Anybody else experience this issue, and any way to mitigate it?
3
0
1.6k
Nov ’23
DeviceActivityMonitor - eventDidReachThreshold Callback Not Triggering Properly
Hello, I'm currently experiencing an issue with the DeviceActivityMonitor extension in my code, specifically with the eventDidReachThreshold callback. I'm hoping to get some insights into why this problem occurs and how to resolve it. Problem: Issue 1: The eventDidReachThreshold callback is not triggering as expected. It appears that the callback is not being invoked when the threshold is reached. Issue 2: After a few seconds, the eventDidReachThreshold callback starts to trigger multiple times. This unexpected behavior is causing problems in my code, as it results in incorrect actions being taken. Issue 3: There are instances where the eventDidReachThreshold callback provides an incorrect event name. iOS version: iOS16.7.2 and iOS17.1.1 Here is my code to start the monitoring: func startMonitoring() { var startTime : DateComponents = DateComponents(hour: 0, minute: 0) let endTime : DateComponents = DateComponents(hour: 23, minute: 59) /// Creates the schedule for the activity, specifying the start a
1
0
1.1k
Nov ’23
DeviceActivityMonitor Schedule Pause
I am trying to understand how to approach 'x minute' pauses for a DeviceActivitySchedule. For instance, I would like to let the user pause for 5 minutes from an active schedule (meaning un-shielding the apps and re-applying the shield after the 5 min has passed). The only way that came to my mind was calling the following: Calling .startMonitoring to start monitoring a new event with the same apps starting .now and ending .now + 5 minutes; Calling in the intervalDidStart, store.shield.applications.subtract(apps) so that the apps are removed from the shield. Calling in the intervalDidEnd, store.shield.applications = apps so that the apps are now shielded again. The problem is that, from the Apple Developer Documentation: The minimum interval length for monitoring device activity is fifteen minutes. So the minimum pause I could offer to the user would be 15 minutes. And that tells me this approach is most likely wrong, because all other Screen Time apps, like Opal, Jomo, AppBlock offer also 5 min pause. Does an
1
0
1.4k
Feb ’24
Reply to How to run Timer into the ShieldActionExtension to wait user for 5 second to unlock the app?
ShieldActionExtensions will exit shortly after the completionHandler is called, so the Timer's closure will likely not be run before your extension's lifecycle ends. A better option would be to use a DeviceActivityMonitor extension. When the secondary button gets pressed, your ShieldActionExtension can create a DeviceActivitySchedule that starts 5 seconds from Date.now and start monitoring that schedule using a DeviceActivityCenter. Your DeviceActivityMonitor extension can then call Restrictions.shared.unlockAllApps() when it receives the intervalDidStart callback for that schedule.
Topic: App & System Services SubTopic: General Tags:
Feb ’23
Reply to Trigger Action After eventDidReachThreshold
Yes, you can create a DeviceActivityMonitor app extension and override its eventDidReachThreshold function. The system will invoke your principal class's implementation of that function whenever an event's threshold is reached. You can create one of these extensions in Xcode by clicking File > New > Target > Device Activity Monitor Extension. Xcode will autogenerate a properly configured extension target with a simple implementation of DeviceActivityMonitor that you can then modify to shield apps whenever a threshold is reached.
Topic: App & System Services SubTopic: General Tags:
Apr ’23
Family Controls entitlement not applying to DeviceActivityMonitor and ShieldConfiguration extensions
I have the Family Controls & Personal Device Usage entitlement approved for my main app target, but I'm unable to get it applied to my app extensions (DeviceActivityMonitor and ShieldConfiguration). The entitlement request form at developer.apple.com/contact shows Thank you for your submission when I submit requests for the extensions, but the requests never actually register. No follow-up email, no change in my account. Without the entitlement on these extensions, I can't use the core Screen Time API functionality (monitoring device activity and displaying shield UIs when apps are blocked). The main app target has the entitlement, but the extensions need it independently to function. Has anyone run into this? Is there a way to get the entitlement extended to app extensions, or is there a step I'm missing in the provisioning process?
0
0
60
2w
Reply to Is the Screen Time API completely broken in the betas?
i have created an extension and changed the identifier to com.apple.deviceactivity.monitor-extension i subclassed DeviceActivityMonitor in my class and designated it as the principal class of my app extension but non of the methods doesn't get called when trying to monitor an activity what method will trigger the extension? is it center.startMonitoring(activity, during: schedule) in that case why non of my extension DeviceActivityMonitor methods doesn't gets called? why calling requestAuthorization on parent device always fails? can anyone upload some sample code that actually do something?
Topic: App & System Services SubTopic: General Tags:
Aug ’21
Reply to Screen Time API How to send restrict information from parent to child
Thank you for your great help. I'm trying to share applicationTokens with DeviceActivityMonitor Extension, but it doesn't work. I tried some way. For example, I tried to save applicationTokens by using UserDefaults. However, I couldn't do it because the data type of applicationTokens isn't appropriate for UserDefaults. I considered other options like key-value or keychain. But, they seem that they can't save the data type of applicationTokens. Do you know how applicationTokens can be saved and can be transmitted to DeviceActivityMonitor Extension?
Topic: App & System Services SubTopic: General Tags:
Jul ’22