Search results for

DeviceActivityMonitor

127 results found

Post

Replies

Boosts

Views

Activity

Reply to Module 'DeviceActivity' not found
I was also able to reproduce this by creating a new barebones project, with adding only two files: MyObjectiveC.m #import MyTestProject-Swift.h and MySwift.swift import DeviceActivity import ManagedSettings import Foundation @objc(MyMonitor) class MyMonitor: DeviceActivityMonitor { }
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’22
Module 'DeviceActivity' not found
I have a class that uses DeviceActivityMonitor as a subclass: // MyMonitor.swift import DeviceActivity @objc(MyMonitor) class MyMonitor: DeviceActivityMonitor { ... } In order to use SwiftUI in Objective-C, I'm importing this in my objective-c file #import MyProject-Swift.h. But, when I try to build, I get the error Module 'DeviceActivity' not found from wthin #import MyProject-Swift.h I've tried Link Binary with Libraries: I've also tried to turn on Define Modules in Build Settings -> Packaging. It just seems as though the DeviceActivity framework doesn't have a header file. Seems like it should? When I click Show in Finder in MyProject -> Frameworks -> DeviceAcitivity.framework, there is not DeviceActivity.h file in that dir (also not in the modules folder in my screenshot): Is there a way to create a header file for an apple framework? Or force the creation of one? I have also tried cleaning the build folder Here's the framework for reference: https://developer.apple.com/document
6
0
1.7k
Dec ’22
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
ScreenTime API
Can the Screen Time API in iOS be used to block specific applications or application categories from getting launched? I went through the documentation here: https://developer.apple.com/videos/play/wwdc2022/110336/ and it indicates that we should be able to block certain app categories using the DeviceActivity and FamilyControl Framework. So, I created the following code snippet: class DeviceActivityMonitorExtension: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) NSLog(interval did start) let model = MyModel.shared let applications = model.selectionToDiscourage.applicationTokens store.shield.applications = applications.isEmpty ? nil : applications store.dateAndTime.requireAutomaticDateAndTime = true } And made a class model var selectionToDiscourage = FamilyActivitySelection() { willSet { NSLog (got here (newValue)) let applications = newValue.applicationTokens let categories = newValu
2
0
3.1k
Sep ’22
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
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
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 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
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
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
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
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