Platforms to show: All Mac Windows Linux Cross-Platform

Back to LAContextMBS class.

LAContextMBS.canEvaluatePolicy(Policy as Integer, byref Error as NSErrorMBS) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TouchBar MBS Mac64bit Plugin 17.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Determines if a particular policy can be evaluated.
Example
try
dim e as NSErrorMBS

if lc.canEvaluatePolicy(lc.PolicyDeviceOwnerAuthenticationWithBiometrics, e) then
List.AddRow "Can authenticate with biometrics."
else
List.AddRow "Can't authenticate with biometrics."
end if
if e <> nil then
List.AddRow "Error: "+e.LocalizedDescription
end if

catch ex as NSExceptionMBS

List.AddRow "Exception: "+ex.Message

end try

Policies can have certain requirements which, when not satisfied, would always cause the policy evaluation to fail. Examples can be a passcode set or a fingerprint enrolled with Touch ID. This method allows easy checking for such conditions.

Applications should consume the returned value immediately and avoid relying on it for an extensive period of time. At least, it is guaranteed to stay valid until the application enters background.

policy: Policy for which the preflight check should be run.

error: contains error information if policy evaluation is not possible.

Returns true if the policy can be evaluated, false otherwise.

Some examples using this method:

LAContextMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TouchBar MBS Mac64bit Plugin 17.0 ✅ Yes ❌ No ❌ No ✅ Yes All
The constructor.

LAContextMBS.evaluatePolicy(Policy as Integer, localizedReason as String, Tag as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TouchBar MBS Mac64bit Plugin 17.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Evaluates the specified policy.
Example
dim lc as LAContextMBS // your context

try

lc.evaluatePolicy(lc.PolicyDeviceOwnerAuthenticationWithBiometrics, "We need to test.")

catch ex as NSExceptionMBS

List.AddRow "Exception: "+ex.Message

end try

Policy evaluation may involve prompting user for various kinds of interaction or authentication. Actual behavior is dependent on evaluated policy, device type, and can be affected by installed configuration profiles.

Be sure to keep a strong reference to the context while the evaluation is in progress. Otherwise, an evaluation would be canceled when the context is being deallocated.

The method does not block. Instead the event is called asynchronously when evaluation finishes.

Implications of successful policy evaluation are policy specific. In general, this
operation is not idempotent. Policy evaluation may fail for various reasons, including
user cancel, system cancel and others, see error codes.

policy: Policy to be evaluated.
localizedReason: Application reason for authentication. This string must be provided in correct localization and should be short and clear. It will be eventually displayed in the authentication dialog subtitle. A name of the calling application will be already displayed in title, so it should not be duplicated here.

Some examples using this method:

LAContextMBS.invalidate

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TouchBar MBS Mac64bit Plugin 17.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Invalidates the context.

The context is invalidated automatically when it is (auto)released. This method allows invalidating it manually while it is still in scope.

Invalidation terminates any existing policy evaluation and the respective call will fail with LAErrorAppCancel. After the context has been invalidated, it can not be used for policy evaluation and an attempt to do so will fail with LAErrorInvalidContext.

Invalidating a context that has been already invalidated has no effect.

LAContextMBS.isCredentialSet(CredentialType as Integer) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TouchBar MBS Mac64bit Plugin 21.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Reveals if credential was set with this context.

type: Type of credential we are asking for.

Return true on success, false otherwise.

LAContextMBS.setCredential(credential as MemoryBlock, Type as Integer) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method TouchBar MBS Mac64bit Plugin 21.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets a credential to this context.

Some policies allow to bind application-provided credential with them.
This method allows credential to be passed to the right context.

credential: Credential to be used with subsequent calls. Setting this parameter to nil will remove any existing credential of the specified type.

Type: Type of the provided credential.

Return true if the credential was set successfully, false otherwise.

The items on this page are in the following plugins: MBS Mac64bit Plugin.


The biggest plugin in space...