Requesting Authorization for Family Controls Returns Invalid Arugment

Hi all, I have a sample app which I created in my local development env. I added the Family Controls capability and the simulator is logged-in to a child account on iCloud that is part of a family group. When I request authorization I keep getting Error Domain=FamilyControls.FamilyControlsError Code=3 "(null)" in the error object returned with the failure result. I am thinking Code 3 represents the enum case for FamilyControlsError which would be invalidArgument. What does that mean and how do I fix it? Also is there a way to map the error object into an FamilyControlsError rather than guess which enum case it is?

Here is my code:


import SwiftUI

import FamilyControls



@main

struct TestScreentimeAPIApp: App {

    @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate



    var body: some Scene {

        WindowGroup {

            ContentView()

        }

    }

}



class AppDelegate: NSObject, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    if #available(iOS 15.0, *) {

            let center = AuthorizationCenter.shared

            center.requestAuthorization { result in

                switch result {

                case .success():

                    break

                case .failure(let error):

                    print("error for screentime is \(error)")
                }

            }

        }
}

I get the same error.

Actually it works for me on iOS 15.0 beta 8 and Xcode beta 13.0 beta 5.

Are you trying to run it in simulator? Try it in real device with child Apple account(has to be part of family sharing) logged in. When, I ran it in simulator received the same error code 3 for the domain FamilyControls.FamilyControlsError.

Requesting Authorization for Family Controls Returns Invalid Arugment
 
 
Q