Search results for

DeviceActivityMonitor

127 results found

Post

Replies

Boosts

Views

Activity

DeviceActivityMonitor for shared devices
Is there a way to use DeviceActivityMonitor to monitor a user's Screen Time ONLY on the current device, even if they have Share Across Devices enabled in their Screen Time settings? For DeviceActivityReport, you can provide a DeviceActivityFilter which can specify the devices you want to show. But I have not seen any way to filter devices with the DeviveActivityMonitor API. I would expect there to be a additional argument to DeviceActivityEvent's init method: init( applications: Set = [], categories: Set = [], webDomains: Set = [], threshold: DateComponents ) Where you can specify devices as well. Right now, it seems like the default behavior is to monitor across all shared devices, which is causing problems for my application.
1
0
921
Sep ’22
Can I read FamilyActivitySelection the container app saved in the Device Activity Report Extension?
In the container app, use FamilyActivityPicker to select some categories & applications, and set a limit usage time. save the result in UserDefaults. in the DeviceActivityMonitor extension, read the saved selection to present the shield. it works. in the DeviceActivityReportScene extension, read the saved selection, in the report add a special icon for categories & applications with limited usage time. it does not work. in the third step, I can read the saved selection, but I can't match the selected data with DeviceActivityResults in the makeConfiguration function.
1
0
1.9k
Jul ’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
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
Jun ’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
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
May ’22
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
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
Apr ’22
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
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
Sep ’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
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