Search results for

DeviceActivityMonitor

127 results found

Post

Replies

Boosts

Views

Activity

DeviceActivityMonitor Extension methods not being triggered
I did a lot of researches, but cannot understand why methods inside DeviceActivityMonitor extension are not calling. What I've seen related to this question and already checked: Do you starting monitoring for schedules? Yes, I do by calling center.startMonitoring() as it has been explained on WWDC2021-10123. I was searching an issue while creating the extension. Walk through steps that are described here. Everything looks good for me. Did you add Family Control Capability to extension's target? Yes, I did. Is your device authorized with FamilyControls? Yes. The only doubt I have here that I'm authorising FamilyControls for .individual . But as I've asked previously, it shouldn’t be a reason. Task { do { guard #available(iOS 16.0, *) else { // Fallback on earlier versions return } try await AuthorizationCenter.shared.requestAuthorization(for: .individual) switch AuthorizationCenter.shared.authorizationStatus { case .notDetermined: print(not determined) case .denied: print(denied) case .approved: print
10
0
2.5k
Feb ’23
Reply to Issues in rendering DeviceActivityController
I can't get anything to print in the functions of my class with the override functions for DeviceActivityMonitor How are you printing in those functions? If you are just using the print function in your extension, those messages will not appear in Xcode's console while you are running your app (this is because your extension is a different process than your app). In order to verify whether or not your extension is logging things, use OSLog and look for your extension's logging in the Console app on your Mac (rather than Xcode's built-in console). I can't get a rendering of a device manager - even when am just sending 0m as a string from the TotalActivityReport's makeConfiguration function without touching the data given. Apologies, but I'm not sure I understand the issue. If you discover problems with the DeviceActivity report APIs, please file a bug report using Feedback Assistant and attach a sample app that reproduces the issue. Thanks in advance!
Topic: App & System Services SubTopic: General Tags:
Feb ’23
How to trigger intervalDidStart in DeviceActivity API?
I have followed the two videos about Screen time API in wwdc 21 and 22. Now i want to sheild some apps during sleeping, but I encounter some problems. Problem I faced I write my monitor and override intervalDidStart and intervalDidEnd . Here is a simplified version class Mymonitor: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) store.shield.applications = selection.applicationToken } then I use deviceActivityCenter to start monitor func StartSleep (_ startTime : DateComponents) { let schedule = DeviceActivitySchedule(intervalStart: startTime, intervalEnd: DateComponents(hour: 4, minute: 0), repeats: true ) let center = DeviceActivityCenter() center.stopMonitoring([.daily]) try! center.startMonitoring(.daily, during: schedule) } However, when I use StartSleep. The applications is not shielded. I have noticed that I haven't use Mymonitor in any place. In the demo Code, it seems i just ne
2
0
1.2k
Feb ’23
Making Network Requests from DeviceActivityMonitor Extension
I am having a lot of trouble reliably making network requests from the DeviceActivityMonitor extension. In the app extension, when intervalDidEnd is called by the system, I add some data to the app's local CoreData store and sync that with the server. I use URLSession dataTask to make a POST request to my server, with URLSessionConfiguration.sharedContainerIdentifier set to my App Group's shared identifier. It is extremely rare that my server receives this request, although sometimes (rarely) it does. I've tried things like wrapping the task in performExpiringActivity or using URLSessionConfiguration.background suspecting that this task needs to run in the background, but none of it seems to work. What I suspect is happening is that the App Extension gets cancelled before the request is able to be invoked. Looking at the console logs, sometimes the work stops before the request is called, sometimes during the request task, and sometimes even before I am able to update my local data store. It's been v
2
0
1.1k
Feb ’23
Reply to Making Network Requests from DeviceActivityMonitor Extension
DeviceActivityMonitor extensions are intended to be very lightweight and their lifecycle ends as soon as the synchronous methods you override return. In other words, your extension will likely exit before a long-running asynchronous background task (like a network request) has the chance to finish. Please file an enhancement request to add support for asynchronous callbacks. As a workaround, you can try using a locking mechanism or a DispatchGroup to force the system to wait on your network request: let waitForMyNetworkRequest = DispatchGroup() waitForMyNetworkRequest.enter() performMyAsyncNetworkRequest { // Talk to your server. // ... // Once you are done, signal the dispatch group. waitForMyNetworkRequest.leave() } // Force the system to wait 3 seconds for your network request. waitForMyNetworkRequest.wait(timeout: 3.0)
Topic: Privacy & Security SubTopic: General Tags:
Feb ’23
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
DeviceActivityCenter stops monitoring if another Screen Time app starts monitoring during the same schedule
I've downloaded another screen time app that uses DeviceActivityMonitor, and once that app starts monitoring during an active monitoring schedule on my app - my app's monitoring schedule immediately ends. Is this expected behavior? Can't find this in any of the docs, but are two separate apps allowed to monitor activities during an overlapping schedule?
1
0
854
Feb ’23
Monitor DeviceActivityEvent for all categories: ActivityCategoryPolicy.all? Without using FamilyActivityPicker
Using ManagedSettings I'm able to shield all categories of applications using ActivityCategoryPolicy.all , without the user using picking categories with the FamilyActivityPicker. I would like to create a DeviceActivityMonitor which monitors events for all (or a specific) categories of apps, without the user needing to interact with the FamilyActivityPicker. Is this possible? And an extra question: is there no way to pick a specific category to shield? Just like we are able to do with ActivityCategoryPolicy.all, instead something like: ActivityCategoryPolicy.games
0
0
1.1k
Feb ’23
DeviceActivityMonitor can't detect private browsing
It seems like private browsing is undetectable with DeviceActivityMonitor for two reasons: Specific web domains do not cause the monitoring threshold callback functions to fire, due to the privacy setting Safari is not able to be monitored as an app or a category. It doesn't appear in the FamilyActivityPicker, and it doesn't appear to belong to any Screen Time category when viewing Safari's information in Screen Time Settings Is there any way to monitor device activity during private browsing? If not, that seems like a big problem for apps that allow parents to set device activity limits for their kids.
1
0
773
Mar ’23
Interact with ManagedSettingsStore from DeviceActivityMonitor
I want to remove shield restrictions for apps. Following the WWDC21 video, I declare ManagedSettingsStore and trying to reset restrictions: class MyDeviceActivityMonitor: DeviceActivityMonitor { let store = ManagedSettingsStore() public override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) store.shield.applications = nil } } Will this string has impact on the app store.shield.applications = nil? Because now, while testing it seems that I'm dealing with two different stores. Or again it is doesn’t synced by default and let store = ManagedSettingsStore() will create store which will be different than store on which the app is relays on? Thank you!
2
0
2.0k
Mar ’23
Reply to Interact with ManagedSettingsStore from DeviceActivityMonitor
Starting in iOS 16, ManagedSettingsStores will share the same settings in the DeviceActivityMonitor extension as the host application. Meaning if you set a setting (like shield.applications) in ManagedSettingsStore() in the app, you will see the same setting in ManagedSettingsStore() in the extension. So, for example this will shield apps in the host application, and clear those same shields once the activity ends. App: func shieldApplications() { let selections = FamilyActivitySelection(includeEntireCategory: true) /* Get Application Tokens from FamilyActivityPicker */ let store = ManagedSettingsStore() store.shield.applications = selections.applicationTokens } Extension: class MyDeviceActivityMonitor: DeviceActivityMonitor { let store = ManagedSettingsStore() public override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) store.shield.applications = nil } } If you do not want this behavior, please use the ManagedSettingsStore(named:) initializer
Topic: App & System Services SubTopic: General Tags:
Mar ’23
DeviceActivity App Extension Lifecycle
I've asked several questions about DeviceActivity performance issues where the answers have cited limitations to the lifecycle of the DeviceActivity App Extensions. For example: Question about DeviceActivityReport lag and performance issues responded letting me know that my extension may be exceeding its memory limit of 100MB and subsequently getting terminated by the system. Question about async tasks in DeviceActivityMonitor responded letting me know that the monitor extensions lifecycle ends and is terminated by the system once all synchronous functions return, so it has no async support. I couldn't find either of these facts documented anywhere, and the DeviceActivity docs mention very little about how the extensions actually work. In general, it seems like these app extensions are basically a black box. Is there any additional comprehensive documentation about the true lifecycle of the app extensions, their limitations, and how apps should handle error cases (like the system terminating the app
1
0
978
Mar ’23
Can we send Local Push Notifications from DeviceActivityMonitor extension?
I'm wondering if we able to send Local Push Notifications from DeviceActivityMonitor extension... If we have to use AppGroups to pass info between an app and the extension, could we post notification though UNNotificationRequest? I also tried to push data through NotificationCenter, also doesn’t work. Can we do so, or did something wrong? Should these cases that I described above work from iOS 16 and above or not? Thank you!
2
0
1.3k
Mar ’23
Reply to Can we send Local Push Notifications from DeviceActivityMonitor extension?
Do you have an example of using App Group to share data? My DeviceActivityMonitor extension is firing the intervalDidStart(), but the categoryTokens in stored in the shared model are empty when it fires. However, when I run it using a button action in the foreground, the categoryTokens are founded and successfully shielded. I tried adding App Group capability to the main app target, and the DeviceActivityMonitorExtension target. Any insight would be appreciated.
Mar ’23