Search results for

DeviceActivityMonitor

127 results found

Post

Replies

Boosts

Views

Activity

Family Controls application-identifier Entitlement error while blocking an application
I was able to start the device activity monitor. I was able to see the Device Activity Monitor Extension as a process, and was able to attach to it via Xcode. Now I am trying block a specific 3rd party application, via the Shield. I am using this piece of code for intervalDidStart : override func intervalDidStart(for activity: DeviceActivityName) { NSLog(Interval started for Device Activity) let blockedApps : Set = [Application(bundleIdentifier: com.facebook.Facebook)] store.application.blockedApplications = blockedApps super.intervalDidStart(for: activity) } I've declared store in the DeviceActivityMonitor class as follows : let store = ManagedSettingsStore() This is the error I see in the Console: Error Domain=UsageTrackingErrorDomain Code=1 Something without a application-identifier entitlement tried to manage usage budgets UserInfo={NSLocalizedDescription=Something without a application-identifier entitlement tried to manage usage budgets} The above use case should work right? I should be able to
6
0
3.1k
Jun ’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
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 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
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 Designate principal class
Use Call directory Extension Template and create an extension. than create a sub class of DeviceActivityMonitor and change that class as a principle class in the info.plist // MyDeviceActivityMonitor import Foundation import DeviceActivity import ManagedSettings class MyDeviceActivityMonitor: DeviceActivityMonitor{ override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) } override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) } override func eventDidReachThreshold(_ event:DeviceActivityEvent.Name,activity:DeviceActivityName){ super.eventDidReachThreshold(event, activity: activity) } } NSExtension NSExtensionPointIdentifier com.apple.deviceactivity.monitor-extension NSExtensionPrincipalClass $(PRODUCT_MODULE_NAME).MyDeviceActivityMonitor
Topic: Business & Education SubTopic: General Tags:
Aug ’21
Selection To Discourage
i'm trying to make my app start blocking/shielding and app according to the selection from a familyActivityPicker. the problem that i'm having is that MyModel object is always nil when i'm accessing it inside the app extension. (DeviceActivityMonitor). can someone give me an example of the object he uses to get the applicationTokens in the app extension? an explanation on how to transfer information between the app and the app extension is also welcome.
1
0
1.3k
Oct ’21
shielding and blocking apps
i'm trying to shield and block apps on child device. i managed to block apps by creating a variable blockedApps : Set = Set() that contains a list of applications like Application(bundleIdentifier: com.apple.calculator) inside the intervalDidStart on my DeviceActivityMonitor extension now i'm trying to shield an app using the same extension and nothing happens. for this i used this code inside intervalDidStart: let calculatorApp = Application(bundleIdentifier: com.apple.calculator) var blockedApps : Set = Set() guard let token = calculatorApp.token else { return } blockedApps = [token] store.shield.applications = blockedApps and i cant tell what is the reason for this not working is there a token issue that is nil? does shielding requires a different app extension? does my app extension requires some additional configuration maybe a different NSExtensionPointIdentifier?
2
0
3k
Nov ’21
FamilyControls DeviceActivityMonitor extension can't change shields
I've been working on a small app using the new FamilyControls API, and I can't get the extension to make any visible changes to shields (or anything else). I can get the main app to authorize and set and remove shields reliably. I can also get the extension to run reliably in the background on a schedule (confirmed with Console). But even if I try only setting the restricted apps to nil or the empty set the apps remain shielded until I run the same code from the main app. I do have the Family Controls entitlement set on both the app and the extension, and I've tried having it off on the extension. I have tried putting both of them into an App Group to no effect. I've wrapped up the most basic working example I can think of into a project: https://github.com/dpowers/ScreenPact Any ideas about what stupid thing I'm missing?
5
0
2.6k
Nov ’21
Reply to How does child can unblock apps for some period of time using Screen Time API?
what your code actually says is: after 30 seconds of total usage of the application that you selected (applications.applicationTokens) the eventDidReachThreshold of the DeviceActivityMonitor extension will be called. handle your event .encouraged inside the eventDidReachThreshold and do there what ever you like. i think for you case if you want to limit some apps for a period of time just make a scheduled event that start from the current time you tapped an OK button (or some other action) to current time + limitation time of tour choice. and on your DeviceActivityMonitor extension you should handle the blocking and unblocking on the intervalDidStart and intervalDidEnd the your code should look something like this: do { let schedule = DeviceActivitySchedule(intervalStart: start, intervalEnd: end, repeats: false, warningTime: nil) try center.startMonitoring(.block, during: schedule) } catch { print(error: + error.localizedDescription) }
Topic: App & System Services SubTopic: General Tags:
Jan ’22
Device Activity Extension not being called
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!
2
0
2.3k
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:
May ’22
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