Search results for

DeviceActivityMonitor

127 results found

Post

Replies

Boosts

Views

Activity

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
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
DeviceActivityMonitor Extension methods not being triggered at IOS16, but its work at IOS17
I'm writing an app that uses Family Control. Most of the functionality has already been debugged, including in the call try deviceActivityCenter.startMonitoring(activityName, during: schedule, events: [ eventName: event ]) Works fine on my IOS17 device, but on my old IOS16 device I found that it can't be called, like intervalDidStart, intervalDidEnd, eventDidReachThreshold etc can't be called. I checked some information, https://forums.developer.apple.com/forums/thread/724243 delete the Build Settings mentioned in this link, and change the ios Deployment Target to ios16, and found that it didn't work. Don't know where the problem is?
0
0
423
Feb ’24
eventDidReachThreshold triggered while target app is in background
Hello! I am using the eventDidReachThreshold callback in the DeviceActivityMonitor in order to shield a target app after the user has spend x amount of time on it (e.g. x = 5 minutes). Many times this works fine, and I can trigger my shield after the specified threshold has been met. However sometimes, when they leave the target app before the threshold has been reached, the eventDidReachThreshold callback gets called randomly while they are doing something else on their phone (e.g. using a different app, on the Home Screen, phone locked…). From my perspective this does not make sense, since they are not actively spending time on the target app, and that time should not be counted towards the target app’s threshold. And it is also very confusing for the users because they will then find a blocked target app even though they haven’t used their time budget completely. This is not related to the intervalDidStart / intervalDidEnd callbacks, because they are not correlating with the timing of when the eve
0
0
667
Mar ’24
DeviceActivityEvent will still execute even if the app is not in use
I use DeviceActivityCenter to monitor app usage. For DeviceActivityEvent, I set 30 events, and the threshold of each event increases by 2 minutes: var events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [:] for index in 0..<30 { let threshold = (index == 29) ? DateComponents(hour: 1) : DateComponents(minute: (index + 1) * 2) let name = DeviceActivityEvent.Name((prefix)|(index)) events[name] = DeviceActivityEvent(applications: tokens, threshold: threshold) } After reaching the last DeviceActivityEvent, I will restart directly in DeviceActivityMonitor private func restartMonitoring(activity: DeviceActivityName) { let center = DeviceActivityCenter() let currentEvents = center.events(for: activity) do { try center.startMonitoring(activity, during: schedule, events: currentEvents) } catch { print(Fail: (error)) } } But I found that after restarting, DeviceActivityEvent will be automatically executed even if I don't use the app. My iOS version is 18.5
0
0
121
Jun ’25
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
61
2w
Failed to fetch a usage budget
Hello! I'm trying to build an app that incorporates the screentime API using a DeviceActivityMonitor extension. I've found a couple public repo's accomplishing what I'm trying to make. When cloning, editing identifiers and app groups, I keep getting this error message when trying to execute the DeviceActivityMonitorExtension Error: Error Domain=UsageTrackingErrorDomain Code=101 Failed to fetch a usage budget UserInfo={NSLocalizedDescription=Failed to fetch a usage budget, NSLocalizedRecoverySuggestion=See Console for additional details.} In mac console it does not show further details, just the same error message lol. This happens on my app as well that was built from scratch under my own identifiers etc. It only occurs when trying to make a call to the extension. I believe my PLists and entitlements are properly setup but I still get this error. The screentime API has been out for a while now and I can't seem to find an answer to my question. I've been trying to battle this for weeks now does anyone
0
0
328
Aug ’24
ScreenTime API: Should the app used by the parent and the child be the same for FamilyActivityPicker to work?
Note: All the devices/accounts mentioned below are part of the same Family Group/ Is it necessary for the parent-side application (that uses FamilyActivityPicker to select the list of restricted apps) to be the same as the child-side application (that will request FamilyControls permission and will implement the DeviceActivityMonitor extension), for FamilyActivityPicker to work as expected? My observation is that given the FamilyControls permission being granted on the child device, FamilyActivityPicker when used on the parent device and rendered on an app with a different bundle identifier works as expected (by populating all the apps installed on the child device) in case of iOS 16 and 17, but does not work for iOS 15 (I am testing on iOS 15.8).
0
0
477
Dec ’23
Family Controls Issues with Multiple Functionalities
I am developing an application that utilizes Family Controls to restrict the use of certain apps. Currently, I am using the following extensions: DeviceActivityMonitor, ShieldConfiguration, and ShieldAction. Issue Overview: While blocking a single application functions correctly, a problem arises when implementing multiple functionalities that use these extensions for the same application. STEPS TO REPRODUCE Functionality 1: Maximum Time in App Description: Blocks the app after 15 minutes of continuous use. Functionality 2: Conscious Opening Description: Upon opening the app, it is blocked for 10 seconds and then automatically unlocked. Steps to Reproduce the Bug: Open the Application: The app opens normally. Trigger Functionality 2 The app is blocked and displays the blocking screen corresponding to Functionality 2: Conscious Opening. Continue Using the App After 10 seconds, the app unlocks, and I continue using it. Important: If the app is closed at this point, the bug does not occur. Trigger Funct
0
0
312
Dec ’24
Device activity extension not being called.
I am new to swift. This is my first app. What an i doing wrong. Device activity monitor extension is never being called. When i launch the app, I am able to pick the discouraged and encouraged apps. It immediately restrict the discouraged app which is expected. But the extension is never called. import SwiftUI import FamilyControls import ManagedSettings @main struct GetALifeApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @StateObject var model = MyModel.shared @StateObject var store = ManagedSettingsStore() var body: some Scene { WindowGroup { ContentView() .environmentObject(model) .environmentObject(store) } } } class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { initiateAsyncSetup() return true } private func initiateAsyncSetup() { Task { do { try await AuthorizationCenter.shared.requestAuthorization(for: .individual) MyS
0
0
723
May ’24
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
Screen Time differences between DeviceActivityMonitor and times shown in DeviceActivityReport
I am still struggling to nail down the screen time between monitoring and showing it in a DeviceActivityReport. It's always off by a couple of percentage points, which results in a difference of a couple of minutes between the time shown for my total screen time in DeviceActivityReport and DeviceActivityMonitor with a threshold set for all apps/websites/categories. In the report, I am looping through all segment (there is only 1 segement using .daily segment interval for a given day) then loop through all categories and all apps within each category and sum up all totalActivityDuration for each app. Based on avaiable documentation, that should corrolate to DeviceActivityMonitor threshold but it doesn't. Are there any differences in how these 2 places count screen time? Are there any apps/core ios services which are excluded from DeviceActivityMonitor. Would appreciate any help at all, I'm losing my mind here. My current suspicion is that Apple Developer documentation is counted twic
0
0
234
Sep ’25
Device Activity monitor extension Not working
anyone has the same problem which is that your device activity extension ain't working even tho all the code work perfectly in the console, I setup it in the right way , tried to make schedule and it did the same exact thing when I tried to create usage threshold. anyone know the reason for this bug? here is my extension code import ManagedSettings import FamilyControls import Foundation import OSLog import UserNotifications class MonitoringExtension: DeviceActivityMonitor { private let defaults = UserDefaults(suiteName: group.com.William.app) private let logger = Logger(subsystem: com.William.app, category: MonitoringExtension) override func eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { let activityRaw = activity.rawValue logger.info(Limite atteinte: (activityRaw)) scheduleNotification(title: Limite dépassée, body: Tu as utilisé trop de temps sur (activityRaw).) guard let data = defaults?.data(forKey: (activityRaw)_selection), let selection = try? JSONDeco
0
0
327
Nov ’25
DeviceActivityMonitor does not trigger UI updates
There is a way to allow DeviceActivityMonitor to make UI changes? Currently I have some code in the intervalDidStart and intervalDidEnd that updates Core Data entities, and it works correctly. However, the changes are only reflected if the app is terminated and opened again. Thus, if the app is opened and one of the methods inside the DeviceActivityMonitor is being called, the UI won't be updated. PS: I am using @FetchRequest to retrieve the core data entities called BlockEntity, and I have a little circle in the UI which should indicate the status of the block: active/inactive, so it would be nice to update the color in real time when intervalDidStart or intervalDidEnd are called.
0
0
698
Mar ’24