Post

Replies

Boosts

Views

Activity

How to create a DeviceActivity Event for only one specific day?
I'm building an app that allows you to configure time limits for specific apps just like the native Screen Time app, but I'm having trouble replicating Screen Time's "Customize Days" feature. I can quite easily create an event that triggers once a particular usage is reached within an activity, but I'm having issues getting different days of the week to have different limits. I'm trying to achieve this by creating different events for each day of the week and assigning them all to a single activity that runs every day: // DeviceActivity receiving event: 00:00 -> 23:59, every day // limits: [UsageLimit(hours: Int, minutes: Int)] let calendar = Calendar(identifier: .gregorian) for (weekday, limit) in limits.days.enumerated() {   let name = DeviceActivityEvent.Name(baseName+"|time-limit-\(weekday)")   events[name] = .init(     applications: selection.applications,     categories: selection.categories,     webDomains: selection.webDomains,     threshold: .init(       calendar: calendar,       hour: limit.hours,       second: limit.minutes,       weekday: weekday + 1     )   ) } The problem I'm having is that weekday is not respected in this context. Unless weekday is nil or 0, the event never triggers. I suppose one way to make this work would be to instead have 7 separate activities that run on different days of the week and contain their respective usage limit event, but I was trying to avoid that as the limit on how many activities you can run at the same time is quite low. What is the intended way to achieve this weekday granularity for events?
1
0
679
Nov ’22
Is FamilyControls not available for macOS?
The documentation states that you can access the new iOS 16 Screen Time APIs on macOS via Catalyst, but it doesn't seem to be completely implemented as the request to authorize instantly fails. The AuthorizationCenter framework itself also can't be accessed at all if you try to build a pure macOS app. It's weird that this is the case given that Screen Time exists for Mac and works just like the iOS counterpart. Will this be available in later betas? (I'm using Xcode 14.1 beta 3)
1
0
738
Oct ’22
How are you supposed to handle ShieldActionDelegate's .defer action?
According to the documentation, your ShieldAction extension can return the .defer action to make iOS ask your ShieldConfiguration extension for a new shield that properly demonstrate this new state. But I don't understand how you're supposed to detect this event in the ShieldConfiguration extension. The API that is called to fetch a configuration is always the same, it contains no context for why it is being called. You also can't store/share any information of your own because you get a new instance every time and the extensions are sandboxed. How are you supposed to determine that a configuration is being requested as a result of the .defer action being triggered in order to return a completely different shield? The WWDC session for this feature shows that this is clearly possible, but it doesn't show the code that achieves it. For context, I'm using Xcode 14.0.
1
1
1.5k
Oct ’22