Instance Method

evaluatePolicy(_:localizedReason:reply:)

Evaluates the specified policy.

Declaration

func evaluatePolicy(_ policy: LAPolicy, localizedReason: String, reply: @escaping (Bool, Error?) -> Void)

Parameters

policy

The policy to evaluate. For possible values, see LAPolicy.

localizedReason

The app-provided reason for requesting authentication, which displays in the authentication dialog presented to the user.

reply

A closure that is executed when policy evaluation finishes. This is evaluated on a private queue internal to the framework in an unspecified threading context. You must not call canEvaluatePolicy(_:error:) in this block, because doing so could lead to deadlock.

success

true if policy evaluation succeeded, otherwise false.

error

nil if policy evaluation succeeded, an error object that should be presented to the user otherwise. See LAError.Code for possible error codes

Discussion

This method asynchronously evaluates an authentication policy. Evaluating a policy may involve prompting the user for various kinds of interaction or authentication. The actual behavior is dependent on the evaluated policy and the device type. The behavior can also be affected by installed configuration profiles.

In the localized string you present to the user in the authentication dialog, provide a clear reason for the authentication request, and describe the resulting action. Make the message short and clear, and provide it in the user’s language. Don’t include the app name, which already appears in the authentication dialog (in macOS, in the title of the dialog; in iOS, in the subtitle).

Don’t assume that a previous successful policy evaluation means that future evaluations will also succeed. Policy evaluation can fail for various reasons, including cancellation by the user or the system.

See Also

Evaluating Authentication Policies

var evaluatedPolicyDomainState: Data?

The current state of the evaluated policy domain.

var maxBiometryFailures: NSNumber?

The number of biometric authentication failures after which the context falls back to another mechanism.

Deprecated
Evaluation Options

Legacy options used in evaluating a policy.