One Logo Pool Ball
_AuthenticationServices_SwiftUI · IOS API REFERENCE

AuthorizationController

struct · iOS 16.4+ · SDK 27.1

@MainActor struct AuthorizationController

A value provided in the SwiftUI environment that views can use to perform authorization requests. Use the ``SwiftUI/Environment`` property wrapper to get an instance of this structure from the ``EnvironmentValues/authorizationController`` environment value. For example, you can perform authorization requests when the user taps a button: struct AuthorizationControllerExample: View { @Environment(\.authorizationController) private var authorizationController var body: some View { Button("Sign In") { Task { do { async let requests = authorizationRequests() // defined elsewhere let result = try await authorizationController .performRequests(requests) switch result { // code to handle the authorization result } } catch { // code to handle the authorization error } } } } }

Members (6)

method · iOS 16.4+

performRequest

TypeScript
performRequestOptions(request: _AuthenticationServices_ASAuthorizationRequest, options: _AuthenticationServices_ASAuthorizationController_RequestOptions): Promise<ASAuthorizationResult>
Swift declaration
@MainActor func performRequest(_ request: ASAuthorizationRequest, options: ASAuthorizationController.RequestOptions) async throws -> ASAuthorizationResult

Perform the authorization request with additional options. For example, you can use ``SwiftUI/View/task(priority:_:)`` or ``SwiftUI/View/task(id:priority:_:)`` along with ``AuthenticationServices/ASAuthorizationController/RequestOptions/preferImmediatelyAvailableCredentials`` to perform an authorization request when the view appears: .task { async let request = authorizationRequest() // defined elsewhere let result = try await authorizationController .performRequest( request, options: .preferImmediatelyAvailableCredentials) switch result { // code to handle the authorization result } } - Parameters: - request: The authorization request to perform. - options: Additional options to customize the behavior of the authorization controller.

method · iOS 16.4+

performRequest

TypeScript
performRequest(request: _AuthenticationServices_ASAuthorizationRequest): Promise<ASAuthorizationResult>
Swift declaration
@MainActor func performRequest(_ request: ASAuthorizationRequest) async throws -> ASAuthorizationResult

Perform the authorization request. For example, you can perform an authorization request when the user taps a button: struct AuthorizationControllerExample: View { @Environment(\.authorizationController) private var authorizationController var body: some View { Button("Sign In") { Task { do { async let request = authorizationRequest() // defined elsewhere let result = try await authorizationController .performRequest(request) switch result { // code to handle the authorization result } } catch { // code to handle the authorization error } } } } } - Parameter request: The authorization request to perform.

method · iOS 16.4+

performRequests

TypeScript
performRequestsOptions(requests: Array<_AuthenticationServices_ASAuthorizationRequest>, options: _AuthenticationServices_ASAuthorizationController_RequestOptions): Promise<ASAuthorizationResult>
Swift declaration
@MainActor func performRequests(_ requests: [ASAuthorizationRequest], options: ASAuthorizationController.RequestOptions) async throws -> ASAuthorizationResult

Perform the authorization requests with additional options. For example, you can use ``SwiftUI/View/task(priority:_:)`` or ``SwiftUI/View/task(id:priority:_:)`` along with ``AuthenticationServices/ASAuthorizationController/RequestOptions/preferImmediatelyAvailableCredentials`` to perform authorization requests when the view appears: .task { async let requests = authorizationRequests() // defined elsewhere let result = try await authorizationController .performRequests( requests, options: .preferImmediatelyAvailableCredentials) switch result { // code to handle the authorization result } } - Parameters: - requests: The authorization requests to perform. - options: Additional options to customize the behavior of the authorization controller.

method · iOS 16.4+

performRequests

TypeScript
performRequests(requests: Array<_AuthenticationServices_ASAuthorizationRequest>): Promise<ASAuthorizationResult>
Swift declaration
@MainActor func performRequests(_ requests: [ASAuthorizationRequest]) async throws -> ASAuthorizationResult

Perform the authorization requests. For example, you can perform authorization requests when the user taps a button: struct AuthorizationControllerExample: View { @Environment(\.authorizationController) private var authorizationController var body: some View { Button("Sign In") { Task { do { async let requests = authorizationRequests() // defined elsewhere let result = try await authorizationController .performRequests(requests) switch result { // code to handle the authorization result } } catch { // code to handle the authorization error } } } } } - Parameter requests: The authorization requests to perform.

method · iOS 16.4+

performAutoFillAssistedRequest

TypeScript
performAutoFillAssistedRequest(request: _AuthenticationServices_ASAuthorizationRequest): Promise<ASAuthorizationResult>
Swift declaration
@MainActor func performAutoFillAssistedRequest(_ request: ASAuthorizationRequest) async throws -> ASAuthorizationResult

Perform the AutoFill-assisted authorization request. Add the ``UIKit/UITextContentType/username`` text content type to the account or login name field: TextField("User name", text: $username) .textContentType(.username) Use ``SwiftUI/View/task(priority:_:)`` or ``SwiftUI/View/task(id:priority:_:)`` to perform an AutoFill-assisted authorization request when the view appears: .task { async let request = autoFillAuthorizationRequest() // defined elsewhere let result = try await authorizationController .performAutoFillAssistedRequest(request) switch result { // code to handle the authorization result } } - Parameter requests: The AutoFill-assisted authorization requests to perform.

method · iOS 16.4+

performAutoFillAssistedRequests

TypeScript
performAutoFillAssistedRequests(requests: Array<_AuthenticationServices_ASAuthorizationRequest>): Promise<ASAuthorizationResult>
Swift declaration
@MainActor func performAutoFillAssistedRequests(_ requests: [ASAuthorizationRequest]) async throws -> ASAuthorizationResult

Perform the AutoFill-assisted authorization requests. Add the ``UIKit/UITextContentType/username`` text content type to the account or login name field: TextField("User name", text: $username) .textContentType(.username) Use ``SwiftUI/View/task(priority:_:)`` or ``SwiftUI/View/task(id:priority:_:)`` to perform AutoFill-assisted authorization requests when the view appears: .task { async let requests = autoFillAuthorizationRequests() // defined elsewhere let result = try await authorizationController .performAutoFillAssistedRequests(requests) switch result { // code to handle the authorization result } } - Parameter requests: The AutoFill-assisted authorization requests to perform.

Skipped declarations

No declarations were skipped in this snapshot.

All _AuthenticationServices_SwiftUI types →