# Proctor SDK (/en/api-reference/api-ref/flexible-classroom/proctor-sdk/ios)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

This Swift API reference covers the Agora Proctor SDK APIs for launching and managing Flexible Classroom proctoring scenarios on iOS.

    ## AgoraProctorSDK [#agoraproctorsdk-2]

    `AgoraProctorSDK` is the basic interface of the Agora Proctor SDK and provides the main methods for a flexible classroom in proctoring scenarios.

    ### init [#init]

    ```swift
    - (instancetype)init:(AgoraProctorLaunchConfig *)config
                delegate:(id<AgoraProctorSDKDelegate> _Nullable)delegate;
    ```

    Initializes the `AgoraProctorSDK` instance.

    **Parameters**

    | Parameter  | Description                                                                                                      |
    | :--------- | :--------------------------------------------------------------------------------------------------------------- |
    | `config`   | Configuration for a flexible classroom. See [AgoraProctorLaunchConfig](#agoraproctorlaunchconfig).               |
    | `delegate` | (Optional) The event handler for the Agora Proctor SDK. See [AgoraProctorSDKDelegate](#agoraproctorsdkdelegate). |

    ### launch [#launch-2]

    ```swift
    - (void)launch:(void (^)(void))success
           failure:(void (^)(NSError *))failure;
    ```

    Launches a flexible classroom in a proctoring scenario.

    **Parameters**

    | Parameter | Description                                                        |
    | :-------- | :----------------------------------------------------------------- |
    | `success` | The callback triggered by a successful launch.                     |
    | `failure` | The callback triggered by a failed launch, which returns an error. |

    ### version [#version]

    ```swift
    - (NSString *)version;
    ```

    Gets the SDK version.

    **Returns**

    The SDK version.

    ## AgoraProctorSDKDelegate [#agoraproctorsdkdelegate]

    `AgoraProctorSDKDelegate` reports events related to SDK status to your app.

    ### didExit [#didexit]

    ```swift
    - (void)proctorSDK:(AgoraProctorSDK *)proctor
               didExit:(AgoraProctorExitReason)reason;
    ```

    This callback is triggered when a user exits or is kicked from the room.

    | Parameter | Description                                                                     |
    | :-------- | :------------------------------------------------------------------------------ |
    | `reason`  | The reason for the exit. See [AgoraProctorExitReason](#agoraproctorexitreason). |

    ## Objects [#objects]

    ### AgoraProctorLaunchConfig [#agoraproctorlaunchconfig]

    ```swift
    @interface AgoraProctorLaunchConfig : NSObject

    @property (nonatomic, copy) NSString *userName;
    @property (nonatomic, copy) NSString *userUuid;
    @property (nonatomic, assign) AgoraProctorUserRole userRole;
    @property (nonatomic, copy) NSString *roomName;
    @property (nonatomic, copy) NSString *roomUuid;
    @property (nonatomic, copy) NSString *appId;
    @property (nonatomic, copy) NSString *token;
    @property (nonatomic, assign) AgoraProctorRegion region;
    @property (nonatomic, strong, nullable) AgoraProctorMediaOptions *mediaOptions;
    @property (nonatomic, copy, nullable) NSDictionary<NSString *, id> *userProperties;
    @property (nonatomic, strong) NSDictionary<NSString *, AgoraWidgetConfig *> *widgets;

    - (instancetype)initWithUserName:(NSString *)userName
                            userUuid:(NSString *)userUuid
                            userRole:(AgoraProctorUserRole)userRole
                            roomName:(NSString *)roomName
                            roomUuid:(NSString *)roomUuid
                               appId:(NSString *)appId
                               token:(NSString *)token;

    - (instancetype)initWithUserName:(NSString *)userName
                            userUuid:(NSString *)userUuid
                            userRole:(AgoraProctorUserRole)userRole
                            roomName:(NSString *)roomName
                            roomUuid:(NSString *)roomUuid
                               appId:(NSString *)appId
                               token:(NSString *)token
                              region:(AgoraProctorRegion)region
                        mediaOptions:(AgoraProctorMediaOptions * _Nullable)mediaOptions
                      userProperties:(NSDictionary * _Nullable)userProperties;
    ```

    The classroom launching configuration used in [launch](#launch).

    | Property         | Description                                                                                                                                                                                                                                                                                                                                             |
    | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    | `userName`       | The user name for display in the classroom. This value must be less than 64 bytes.                                                                                                                                                                                                                                                                      |
    | `userUuid`       | The user ID. This is the globally unique identifier of a user. This value must be the same as the User ID that you use for generating a Signaling token. The string length must be less than 64 bytes. Supported characters include lowercase and uppercase English letters, numbers, spaces, and the symbols listed in the Web `userUuid` description. |
    | `userRole`       | The user's role in the classroom. See [AgoraProctorUserRole](#agoraproctoruserrole).                                                                                                                                                                                                                                                                    |
    | `roomName`       | The room name for display in the classroom. The string length must be less than 64 bytes.                                                                                                                                                                                                                                                               |
    | `roomUuid`       | The room ID. This is the globally unique identifier of a classroom. This value must be less than 64 bytes. Supported characters include lowercase and uppercase English letters, numbers, spaces, and the symbols listed in the Web `userUuid` description.                                                                                             |
    | `appId`          | The Agora App ID. See [Get the Agora App ID](/en/realtime-media/flexible-classroom/build/manage-agora-account#get-the-app-id).                                                                                                                                                                                                                          |
    | `token`          | The Signaling token used for authentication. See [Secure authentication with tokens](/en/realtime-media/flexible-classroom/build/set-up-your-account-and-authentication/authentication-workflow).                                                                                                                                                       |
    | `region`         | The region where the classrooms are. All clients must use the same region to communicate with each other. Supported regions are `CN` for Mainland China, `NA` for North America, `EU` for Europe, and `AP` for Asia Pacific.                                                                                                                            |
    | `mediaOptions`   | Media options, including the media stream encryption configuration. See [AgoraProctorMediaOptions](#agoraproctormediaoptions).                                                                                                                                                                                                                          |
    | `userProperties` | User properties customized by the developer.                                                                                                                                                                                                                                                                                                            |
    | `widgets`        | Pass in `widgetId` and `AgoraWidgetConfig`.                                                                                                                                                                                                                                                                                                             |

    ### AgoraProctorMediaOptions [#agoraproctormediaoptions]

    ```swift
    @interface AgoraProctorMediaOptions : NSObject
    @property (nonatomic, strong, nullable) AgoraProctorMediaEncryptionConfig *encryptionConfig;
    @property (nonatomic, strong, nullable) AgoraProctorVideoEncoderConfig *videoEncoderConfig;
    @property (nonatomic, assign) AgoraProctorLatencyLevel latencyLevel;

    - (instancetype)initWithEncryptionConfig:(AgoraProctorMediaEncryptionConfig * _Nullable)encryptionConfig
                          videoEncoderConfig:(AgoraProctorVideoEncoderConfig * _Nullable)videoEncoderConfig
                                latencyLevel:(AgoraProctorLatencyLevel)latencyLevel;
    ```

    Media options. Set in [AgoraProctorLaunchConfig](#agoraproctorlaunchconfig).

    | Property             | Description                                                                                                                                                                                               |
    | :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `encryptionConfig`   | (Optional) The media stream encryption configuration. See [AgoraProctorMediaEncryptionConfig](#agoraproctormediaencryptionconfig).                                                                        |
    | `videoEncoderConfig` | (Optional) The video encoder configuration. See [AgoraProctorVideoEncoderConfig](#agoraproctorvideoencoderconfig).                                                                                        |
    | `latencyLevel`       | The latency level of an audience member. This property does not apply to cohosting users. The default value is `low`, which means low latency. See [AgoraProctorLatencyLevel](#agoraproctorlatencylevel). |

    ### AgoraProctorMediaEncryptionConfig [#agoraproctormediaencryptionconfig]

    ```swift
    @interface AgoraProctorMediaEncryptionConfig : NSObject
    @property (nonatomic, assign) AgoraProctorMediaEncryptionMode mode;
    @property (nonatomic, copy) NSString *key;

    - (instancetype)initWithMode:(AgoraProctorMediaEncryptionMode)mode
                             key:(NSString *)key;
    ```

    The media stream encryption configuration used in [AgoraProctorMediaOptions](#agoraproctormediaoptions).

    | Property | Description                                                                                   |
    | :------- | :-------------------------------------------------------------------------------------------- |
    | `mode`   | The encryption mode. See [AgoraProctorMediaEncryptionMode](#agoraproctormediaencryptionmode). |
    | `key`    | The encryption key.                                                                           |

    ### AgoraProctorVideoEncoderConfig [#agoraproctorvideoencoderconfig]

    ```swift
    @interface AgoraProctorVideoEncoderConfig : NSObject
    @property (nonatomic, assign) NSUInteger dimensionWidth;
    @property (nonatomic, assign) NSUInteger dimensionHeight;
    @property (nonatomic, assign) NSUInteger frameRate;
    @property (nonatomic, assign) NSUInteger bitRate;
    @property (nonatomic, assign) AgoraProctorMirrorMode mirrorMode;

    - (instancetype)initWithDimensionWidth:(NSUInteger)dimensionWidth
                           dimensionHeight:(NSUInteger)dimensionHeight
                                 frameRate:(NSUInteger)frameRate
                                   bitRate:(NSUInteger)bitRate
                                mirrorMode:(AgoraProctorMirrorMode)mirrorMode;
    ```

    The video encoder configuration used in [AgoraProctorMediaOptions](#agoraproctormediaoptions).

    | Property          | Description                                                                                                                                                                             |
    | :---------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `dimensionWidth`  | The width of the video frame in pixels. The default value is 320.                                                                                                                       |
    | `dimensionHeight` | The height of the video frame in pixels. The default value is 240.                                                                                                                      |
    | `frameRate`       | The frame rate of the video in FPS. The default value is 15.                                                                                                                            |
    | `bitRate`         | The bitrate of the video in Kbps. The default value is 200.                                                                                                                             |
    | `mirrorMode`      | Whether video mirror mode is enabled. The default value is `AgoraProctorMirrorModeDisable`, which means mirror mode is disabled. See [AgoraProctorMirrorMode](#agoraproctormirrormode). |

    ## Enums [#enums]

    ### AgoraProctorMirrorMode [#agoraproctormirrormode]

    Whether to enable mirror mode, used in [AgoraProctorVideoEncoderConfig](#agoraproctorvideoencoderconfig).

    | Value      | Description               |
    | :--------- | :------------------------ |
    | `disabled` | `0`: Disable mirror mode. |
    | `enabled`  | `1`: Enable mirror mode.  |

    ### AgoraProctorRegion [#agoraproctorregion]

    The region where classrooms are, used in [AgoraProctorLaunchConfig](#agoraproctorlaunchconfig).

    | Value | Description          |
    | :---- | :------------------- |
    | `CN`  | `0`: Mainland China. |
    | `NA`  | `1`: North America.  |
    | `EU`  | `2`: Europe.         |
    | `AP`  | `3`: Asia Pacific.   |

    ### AgoraProctorExitReason [#agoraproctorexitreason]

    The reason for exiting the Agora Proctor SDK, used in the [didExit](#didexit) callback.

    | Value     | Description                     |
    | :-------- | :------------------------------ |
    | `normal`  | User exits the room normally.   |
    | `kickOut` | User is kicked out of the room. |

    ### AgoraProctorLatencyLevel [#agoraproctorlatencylevel]

    The latency level of an audience member, used in [AgoraProctorLaunchConfig](#agoraproctorlaunchconfig).

    | Value      | Description                                                                                       |
    | :--------- | :------------------------------------------------------------------------------------------------ |
    | `low`      | `1`: Low latency. The latency from the sender to the receiver is between 1500 ms and 2000 ms.     |
    | `ultraLow` | `2`: Ultra-low latency. The latency from the sender to the receiver is between 400 ms and 800 ms. |

    ### AgoraProctorUserRole [#agoraproctoruserrole]

    The user role in the classroom, used in [AgoraProctorLaunchConfig](#agoraproctorlaunchconfig).

    | Value       | Description           |
    | :---------- | :-------------------- |
    | `invalid`   | `0`: Recording robot. |
    | `teacher`   | `1`: Teacher.         |
    | `student`   | `2`: Student.         |
    | `assistant` | `3`: Assistant.       |
    | `observer`  | `4`: Observer.        |

    ### AgoraProctorMediaEncryptionMode [#agoraproctormediaencryptionmode]

    The media stream encryption mode, used in [AgoraProctorMediaEncryptionConfig](#agoraproctormediaencryptionconfig).

    | Value        | Description                                                                                                                      |
    | :----------- | :------------------------------------------------------------------------------------------------------------------------------- |
    | `None`       | `0`: No encryption.                                                                                                              |
    | `AES128XTS`  | `1`: 128-bit AES encryption, XTS mode.                                                                                           |
    | `AES128ECB`  | `2`: 128-bit AES encryption, ECB mode.                                                                                           |
    | `AES256XTS`  | `3`: 256-bit AES encryption, XTS mode.                                                                                           |
    | `SM4128ECB`  | `4`: 128-bit SM4 encryption, ECB mode.                                                                                           |
    | `AES128GCM`  | `5`: 128-bit AES encryption, GCM mode.                                                                                           |
    | `AES256GCM`  | `6`: 256-bit AES encryption, GCM mode.                                                                                           |
    | `AES128GCM2` | `7`: Enhanced 128-bit AES encryption, GCM mode. Compared with `AES128GCM`, this mode is more secure and requires setting a salt. |
    | `AES256GCM2` | `8`: Enhanced 256-bit AES encryption, GCM mode. Compared with `AES256GCM`, this mode is more secure and requires setting a salt. |

    
  
