Hey, I was wondering on how to react to the focus mode being turned off inside the FocusFilterIntent. I've successfully managed to call a specific action when the focus is being set, but I now want to deactivate/ react when the focus is being deactivated. How can I achieve something like this?
Post
Replies
Boosts
Views
Activity
Core Data not returning results in ShieldConfiguration Extension, but works fine in other extensions
Hi everyone,
I’m using Core Data in several extensions (DeviceActivityMonitor, ShieldAction, and ShieldConfiguration). It works perfectly in DeviceActivityMonitor and ShieldAction. I’m able to successfully fetch data and log the correct count using a fetch request.
However, when I try the same setup in the ShieldConfiguration extension, the fetch request always returns 0 results. The CoreData and App Group setup appears to be correct since the first two extensions fetch the expected data.
I’ve also previously tested storing the CoreData objects separately in a JSON-FIle using FileManager and it worked without issues—though I’d prefer not to handle manual encoding/decoding if possible.
The documentation mentions that the extension runs in a sandbox, restricting network requests or moving sensitive content. But shouldn’t reading data (from a shared App Group, for instance) still be possible within the sandbox, as it is the case with the Files, what is the difference there? In my case, I only need to read the data, as modifications can be handled via ShieldActionExtension.
Any help would be greatly appreciated!
Hi everyone,
I’m encountering an issue with shield.applicationCategories = .all(except: applications.applicationTokens) when trying to shield all apps except a specified few. Despite using this configuration, all apps are getting shielded, including those that should be exempt.
I’ve verified that the correct applicationTokens are being used and ensured that there are no conflicting schedules that might override this configuration. Interestingly, the ShieldConfiguration appears for the apps that are supposed to be blocked, but not for the ones in the exception list.
Has anyone else experienced this issue, or does anyone have insights into what might be causing this behavior?
Thanks in advance!
Hey everyone,
I'm working on implementing an AppLimit, where after accumulating x minutes of Screen Time for an app, it should be blocked. It works fine on the first day, but stops functioning correctly on subsequent days.
What I'm Doing
I start a 24/7 schedule with a DeviceActivityEvent that has a specified Screen Time threshold.
In my DeviceActivityMonitor, I'm reacting to the eventDidReachThreshold. Once the accumulated time is reached, the app is blocked. This works as expected on the first day.
Issues I'm Experiencing / Questions
Second Day Issue: On the second day, the app is no longer blocked after the Screen Time threshold is reached, even though it worked on the first day. This leads me to suspect that a DeviceActivityEvent is "consumable". Is this correct?
Pre-existing Screen Time Issue: If a user has already surpassed the Screen Time threshold before monitoring starts, the app isn't blocked once the schedule is set up. This leads to 2 issues:
I would expect that the accumulated amount of time after starting the schedule would result in the call of eventDidReachThreshold. But it is never called
It could also be the case that the previously accumulated time is being kept in mind, but that would mean the apps should be blocked, which isn't the case.
Does the threshold account for accumulated Screen Time before the schedule begins? I haven't tested setting a limit of 10 minutes, accumulating 3 minutes of Screen Time, then starting the schedule and accumulating the remaining time, but I'm curious if anyone has encountered this behavior.
Does anyone have an explanation for this behavior? Any help would be greatly appreciated!
Hi everyone,
I'm trying to find out if there's a way to mock Screen Time for a specific app (either on a real device or in a simulator). Specifically, I need to set the usage time of an app to something like 15 minutes. I'm not looking to alter the total Screen Time, just the usage time for a single app.
Currently, I'm manually keeping the app open for 15 minutes before I can start testing to see if the desired behavior occurs, but this process is slow and frustrating. Unfortunately, I can't reduce the 15-minute threshold, as Apple doesn't allow it for this particular use case.
Any advice or solutions would be greatly appreciated!
Hi everyone,
I'm currently working with the Screen Time API, specifically trying to figure out the best way to pause an active, repeating schedule without disrupting future schedules. Here's the scenario:
I have a repeating schedule set from 10:00 AM to 8:00 PM daily. If I need to pause the schedule temporarily, my current approach involves stopping monitoring, clearing all restrictions, and then setting a new schedule for the remaining time after the pause. However, this method cancels the repeating schedule entirely, which causes issues when the schedule is supposed to restart the next day at 10:00 AM. Instead, it starts after the pause time, which isn’t what I want.
Challenges I'm Facing:
Maintaining Repeating Schedules:
How can I pause the schedule in a way that ensures it resumes correctly the next day at the intended time (10:00 AM)?
DeviceActivityMonitor Logic:
Is there a way to deactivate and reactivate the schedule through the DeviceActivityMonitor without fully stopping the monitoring? Ideally, I'd like to retain the original schedule, pause it, and then resume it seamlessly after the pause.
What I’ve Tried So Far:
I’ve attempted to store the necessary data in the App Groups shared container as a local file. In the DeviceActivityMonitor, I used the schedule's name to identify and retrieve the saved object, planning to use this data to reapply the shielding after the pause. Unfortunately, this approach exceeds the 6MB memory limit of the extension, which is another roadblock.
Given these issues, I’m unsure how to move forward. Are there any best practices or alternative approaches that could help manage this situation more effectively? Any insights or suggestions would be greatly appreciated!
Thanks in advance for your help.
I'm currently exploring how to implement the AppIntent parameter with a list of apps similar to what's shown in the screenshots provided below:
I'm particularly interested in how the searchable list of apps is implemented. My current approach involves creating an enum for the apps, but it lacks searchability and requires manual addition of each app.
Does anyone have an idea on how this functionality might be implemented? It appears that the searchable list might be a native Apple view, but I haven't been able to find any documentation or resources on it. Any insights or pointers would be greatly appreciated!
I'm using the Screen Time API to shield apps the user selects. The problem is, that the apps are always shielded, even outside of the schedule. Here is my function initiateMonitoring:
func initiateMonitoring(scheduleStart: DateComponents, scheduleEnd: DateComponents) {
let schedule = DeviceActivitySchedule(
intervalStart: scheduleStart,
intervalEnd: scheduleEnd,
repeats: true
)
let center = DeviceActivityCenter()
do {
try center.startMonitoring(.daily, during: schedule)
logger.log("STARTED MONITORING")
} catch {
logger.log("FAILED MONITORING: \(error.localizedDescription)")
}
}
The expected result should be that the selected Apps should be blocked during the schedule the user specified, but not outside the schedule, but it is blocked 24/7. I've experimented with the DateComponents, but the issue may be somewhere else.
What's maybe interesting is, I tried Logging the DeviceActivityMonitor and somehow it doesn't get called. The logging-output from initiateMonitoring is printed in the console, but for the DeviceActivityMonitor it's not. I implemented it as recommended as a separate Extension Target. For more context, here is my DeviceActivityMonitor:
class DeviceActivityMonitorExtension: DeviceActivityMonitor {
let store = ManagedSettingsStore()
let logger = Logger()
override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
logger.log("INTERVAL STARTED")
let model = ShieldManager.shared
let applications = model.selectionToDiscourage.applicationTokens
let categories = model.selectionToDiscourage.categoryTokens
let webCategories = model.selectionToDiscourage.webDomainTokens
store.shield.applications = applications.isEmpty ? nil : applications
store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.specific(categories, except: Set())
store.shield.webDomains = webCategories.isEmpty ? nil : webCategories
}
...
What's confusing me is that the apps are in fact shielded, so the MonitorExtension should be called, but neither the logging works nor my separate ShieldConfigurationExtension, maybe the issues are connected...
Any help would be gladly appreciated!
I want to block specific Websites with FamilyControls in my App. To do this, I need to access the WebDomainTokens of a specific Website, without the user selecting it in the FamilyActivityPicker. I basically just want to have a button e.g. "Block Instagram" and when clicking it, the instagram website is blocked. I don't see any way in accessing the WebDomainToken without the FamilyActivityPicker. Or is there maybe another approach to this problem?
Currently I tried the following:
var selectionToDiscourage = FamilyActivitySelection() {
willSet {
let applications = newValue.applicationTokens
store.shield.applications = applications.isEmpty ? nil : applications
let webDomain: WebDomain = .init(domain: "https://www.instagram.com/")
print("TOKEN: \(webDomain.token)")
print("DOMAIN: \(webDomain.domain)")
if let webDomainToken = webDomain.token {
let webDomainTokenSet: Set<WebDomainToken> = [webDomainToken]
store.shield.webDomains = webDomainTokenSet
}
}
}
But when only giving the domain, the token always prints nil.
Hope someone can help!
I have implemented a shielding mechanism via Family Controls to prevent unauthenticated users from deleting specific shortcuts within the Shortcuts app. While this successfully secures the app, it has an unintended consequence: the Shortcuts app no longer appears in Spotlight Search and becomes inaccessible for users subject to this shielding. I understand that this is the default behavior when implementing app shielding or time limits on specific apps. Is there a way to retain the app's visibility in Spotlight Search despite it being shielded?