AuthorizationCenter
The center for requesting authorization to provide parental controls.
Declaration
class AuthorizationCenterOverview
To authorize your app so that it can provide parental controls, access the shared AuthorizationCenter instance.
let center = AuthorizationCenter.sharedNext, to request authorization to provide parental controls, call requestAuthorization(completionHandler:)
center.requestAuthorization { result in
switch result {
case .success():
// The request succeeded.
case .failure(let error):
// Handle the error here.
}
}or requestAuthorization(for:).
do {
try await center.requestAuthorization(for: FamilyControlsMember.individual)
} catch {
// Handle the error here.
}Always request authorization when your app first launches. If the user’s parent or guardian hasn’t previously authorized your app, the system displays an alert. If the parent or guardian chooses to continue, it displays an authentication sheet. When a parent or guardian either approves or cancels the request, the system sends the result back to the requestAuthorization(completionHandler:) method’s completion handler.
If you’re authenticating an individual who hasn’t previously authorized your app, the system displays an alert. If the individual chooses to continue, the device asks to authorize that individual using Face ID or Touch ID.
After your app has been authorized, additional calls to requestAuthorization(for:) don’t display the authentication sheet or ask to authorize that individual using Face ID or Touch ID. Instead, the system sets the authorization status.
To observe changes to the authorization status, use the authorizationStatus property.
The status may change due to external events, such as a child graduating to an adult account, or a parent or guardian changing the status in Settings. You can also revoke authorization by calling revokeAuthorization(completionHandler:)