Instance Method


Prepares the interface to display a list of credentials from which the user can select.


- (void)prepareCredentialListForServiceIdentifiers:(NSArray<ASCredentialServiceIdentifier *> *)serviceIdentifiers;



An array of service identifiers that provide a hint about the service for which the user needs credentials.


The system calls this method to tell your extension’s view controller to prepare to present a list of credentials. After calling this method, the system presents the view controller to the user.

Use the given serviceIdentifiers array to filter or prioritize the credentials to display. The service identifier array might be empty, but your extension should still show credentials from which the user can pick.

Items in the array with lower indices represent more specific identifiers for which a credential is requested. For example, if the array contains identifiers [,], the item represents the more specific service that requires a credential.

When the user selects a credential displayed by your view controller, encapsulate the corresponding user and password strings in an ASPasswordCredential instance and pass it to the extension context’s completeRequestWithSelectedCredential:completionHandler: method:

let passwordCredential = ASPasswordCredential(user: user, password: password)
extensionContext.completeRequest(withSelectedCredential: passwordCredential)

Alternatively, if the user cancels the operation, call the cancelRequestWithError: method instead with an error that indicates user cancelation:

let error = NSError(domain: ASExtensionErrorDomain,
                    code: ASExtensionError.userCanceled.rawValue)
extensionContext.cancelRequest(withError: error)

Always provide a way for the user to cancel the operation from your view controller, for example by including a cancel button in the navigation bar.

The system dismisses your view controller automatically after you call either the completion or cancelation method.

See Also

Selecting a Credential


An identifier representing a particular service for which the user needs a credential, like a web site.