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 = newValue.categoryTokens
let webCategories = newValue.webDomainTokens
store.shield.applications = applications.isEmpty ? nil : applications
store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.specific(categories, except: Set())
store.shield.webDomains = webCategories
}
}
I expected it to block the launch of any application, but it does not happen.
Any idea what I might be missing here? I have already added Family Controls capability to my application. Do I need any others?