A session that your app uses to protect an assessment.


class AEAssessmentSession : NSObject


Use the AEAssessmentSession class to manage an assessment session. The system allows only one active session at a time across all processes. The first session to run gets exclusive access to the system; subsequent session attempts fail until the first session ends.

To create an assessment session, pass a new AEAssessmentConfiguration instance to the init(configuration:) method. Then, provide the session with a delegate that conforms to the AEAssessmentSessionDelegate protocol:

let config = AEAssessmentConfiguration()
let session = AEAssessmentSession(configuration: config)
session.delegate = self

The session tells its delegate about state changes during its life cycle. To start a session, call the session’s begin() method:


The method returns immediately, and the session starts disabling system features. After achieving the desired state, the session calls its delegate’s assessmentSessionDidBegin(_:) method. Only after receiving this callback is it safe to begin your assessment. Be sure to keep a strong reference to the session as long as you want it to remain active. If the system deallocates an active session, the session automatically ends.

After completing an assessment and hiding all sensitive information, call the session’s end() method:


After making the call, wait for the session to call its delegate’s assessmentSessionDidEnd(_:) method before reporting assessment completion to the user.

During assessment, the session’s delegate might receive an assessmentSession(_:wasInterruptedWithError:) callback to indicate a failure. If this happens, immediately stop the assessment, hide all sensitive content, and end the session. Because it might take time for your app to finalize the assessment, the session relies on your app to call the session’s end() method:

func assessmentSession(_ session: AEAssessmentSession, wasInterruptedWithError error: Error) {
    // Hide sensitive UI and optionally store assessment progress.

    // End the session.


Creating a Session

init(configuration: AEAssessmentConfiguration)

Creates a new assessment session.

class AEAssessmentConfiguration

Configuration information for an assessment session.

Responding to Session Updates

var delegate: AEAssessmentSessionDelegate?

A delegate to which the session provides state change updates.

protocol AEAssessmentSessionDelegate

An interface that the session uses to provide information about session state changes to a delegate.

Starting and Stopping a Session

func begin()

Starts an assessment session.

func end()

Ends an assessment session.

var isActive: Bool

A Boolean that indicates whether an assessment session is running.


Inherits From

Conforms To