A mechanism for generating requests to authenticate users based on their Apple ID.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
Framework
- Authentication
Services
Declaration
class ASAuthorizationAppleIDProvider : NSObject
Overview
You use a provider to create a request (ASAuthorization
), which you then use to initialize a controller (ASAuthorization
) that performs the request:
let provider = ASAuthorizationAppleIdProvider()
let request = provider.createRequest()
let controller = ASAuthorizationController(authorizationRequests: [request])
On success, the controller’s delegate receives an authorization (ASAuthorization
) containing a credential (ASAuthorization
) that has an opaque user
identifier. You can use that identifier to later check the user’s credential state—for example, to see if authorization has been revoked—by calling the get
method:
let user = authorization.credential.user
provider.getCredentialState(forUserID: user) { state, error in
// Check for error and examine the state.
}