I've implemented shielding apps with new Screentime API. But I don't know how to shield all categories app except the app selected by user in the FamilyActivityPicker? Here is my code to shield apps and it worked. But I want to know if I could shield all apps and all "categories" except the apps user selected. I want to allow only the apps and categories that user has selected.
let store = ManagedSettingsStore()
if let object = UserDefaults.standard.object(forKey: "SelectedAppTokens") as? Data {
let decoder = JSONDecoder()
if let appTokens = try? decoder.decode(Set<ApplicationToken>.self, from: object) {
store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.all(except: appTokens)
}
}
I save 'applicationTokens' from FamilyActivityPicker and shield with it.