'Swift Screen time Api error (family controls error code=2 )

I'm try to physical device always getting error on Error for Family Controls: Error Domain=FamilyControls.FamilyControlsError Code=2 "(null)"

AuthorizationCenter.shared.requestAuthorization { result in                  
    switch result {        
        case .success():           
            break         
        case .failure(let error):           
           print("Error for Family Controls: (error)") 
    }
}


Solution 1:[1]

check out this link at Apple Developer Forums it says:

Requesting FamilyControls authorization on Simulator is supported by the ScreenTime API. FamilyControlsError Code=2 is the error code for an invalid account type; this is expected when trying to authorize FamilyControls on a non-child iCloud account. FamilyControlsError Code=3 is an internal error, which isn't expected.

I hope it'll help you. Have a nice day mate !

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 A.David