Implementing Screen Time API’s .all(except:) Policy for Selective App Restrictions

Hi there,

I'm currently working with the Screen Time API using the family controls package to manage application usage on iOS devices. I want to block access to all applications except those specifically allowed by the user. While the ManagedSettingsStore.shield.applications method works for defining apps to block. However, integrating the .all(except:) from ShieldSettings.ActivityCategoryPolicy.all(except:) is unfortunately not working for me.

Here is my code snippit. Can anyone help out? And if anyone has examples of similar implementations or tips on best practices for using the Screen Time API for such scenarios, please let me know!

class ShieldManager: NSObject, ObservableObject, NFCNDEFReaderSessionDelegate {
    @Published var discouragedSelections = FamilyActivitySelection()
    
    private let store = ManagedSettingsStore()
    
    func shieldActivities() {
        // Clear to reset previous settings
        store.clearAllSettings()
                     
        // This is an array with the app and category selection
        let applications = discouragedSelections.applicationTokens
        let categories = discouragedSelections.categoryTokens
        //
        
        //https://developer.apple.com/documentation/managedsettings/shieldsettings/activitycategorypolicy
        store.shield.applications = applications.isEmpty ? nil : applications
        store.shield.applicationCategories = categories.isEmpty ? nil : .specific(categories)
        store.shield.webDomainCategories = categories.isEmpty ? nil : .specific(categories)
    }

f

I am also looking to implement this functionality. Can anyone from Apple respond?

The use-case is this : Suppose the user wants to study and at that time, he only wants to allow a few apps.

Currently, the picker only lets you select apps to block. Is there a way to allow developers to implement apps to allow?

Hello,

from the documentation, this API should work how you described:

A policy that indicates the device shields all apps and websites, except content that you specify.

However, it does not seem to work how documented, because the apps that are specified under except are still shielded, but with a generic shield that just says "Restricted" (even though it shouldn't be shielded at all).

Similar unexpected behavior has been reported here as well: https://forums.developer.apple.com/forums/thread/762287

Implementing Screen Time API’s .all(except:) Policy for Selective App Restrictions
 
 
Q