Classroom SDK & Proctor SDK
Updated
Integrate the Classroom SDK or Proctor SDK into your app with the default UI or a customized UI.
This page introduces how to add Flexible Classroom into your app.
iOS
Understand the tech
Flexible Classroom contains the following libraries:
AgoraClassroomSDK: The integration layer that connectsAgoraEduUIandAgoraEduCore.AgoraClassroomSDKis an open sourced project and is released on GitHub and CocoaPods.AgoraEduUI: This library contains the code for the UI; it also includes all the texts and resource files used by Flexible Classroom.AgoraEduCoreprovides this library with the functionality and data in Flexible Classroom.AgoraEduUIis an open source project and is released on GitHub and CocoaPods.AgoraProctorSDK: The integration layer of the Flexible Classroom proctoring use-case, connectingAgoraProctorUIandAgoraEduCore.AgoraProctorSDKis an open sourced project on GitHub and CocoaPods.AgoraProctorUI: The interaction layer code for the Flexible Classroom proctoring use-case. It includes the copy information and resource files used in the interaction layer.AgoraEduCoreprovides this layer with the capabilities and data.AgoraProctorUIis an open sourced project on GitHub and CocoaPods.AgoraEduCore: This library provides the capabilities and data in Flexible Classroom.AgoraEduCoreis a closed-source library and is released on CocoaPods as a binary package.Widget: This library provides independent plugins that include both interfaces and functions.AgoraClassroomSDKinjects these plugins into Flexible Classroom. Widgets can communicate with each other.
The following figure shows the structure of Flexible Classroom:
Prerequisites
Use CocoaPods v1.10 or higher for the integration methods described below.
After installation, enter the following command in the terminal to see if the installation was successful:
pod --versionFor example, if you install version 1.11.3, the terminal should print the following information:
1.11.3Education use-case
Flexible Classroom in the integrated education use-case (default)
To use the default UI of Flexible Classroom, take the following steps to add remote dependencies and integrate the whole Flexible Classroom through CocoaPods:
-
Open your project with Xcode and add the following code to the project's
Podfile:# third-party libs pod 'SwifterSwift', '5.2.0' pod 'Masonry', '1.1.0' pod 'SDWebImage', '5.12.0' pod 'AgoraRtcEngine_Special_iOS', '3.7.2.133' pod 'Whiteboard', :git => 'https://github.com/netless-io/Whiteboard-iOS', :branch => 'effect-mixing' # open source libs pod 'AgoraClassroomSDK_iOS', '2.8.111' pod 'AgoraWidgets', '2.8.111' -
Navigate into the project directory in the terminal and run
pod installto install the dependencies. For example, the following will be printed for v2.80.20:Analyzing dependencies Downloading dependencies Installing AgoraClassroomSDK_iOS (2.8.20) Installing AgoraEduCore (2.8.20) Installing AgoraEduUI (2.8.20) Installing AgoraLog (1.0.2) Installing AgoraMediaPlayer_iOS (1.3.0) Installing AgoraRtcEngine_iOS (3.7.2) Installing AgoraRtm_iOS (1.4.8) Installing AgoraUIBaseViews (2.8.0) Installing AgoraWidget (2.8.0) Installing AgoraWidgets (2.8.20) Installing Agora_Chat_iOS (1.0.6) Installing AliyunOSSiOS (2.10.8) Installing Armin (1.1.0) Installing CocoaLumberjack (3.6.1) Installing Masonry (1.1.0) Installing NTLBridge (3.1.5) Installing Protobuf (3.17.0) Installing SDWebImage (5.12.0) Installing SSZipArchive (2.4.2) Installing SwifterSwift (5.2.0) Installing Whiteboard (2.16.51) Installing YYModel (1.0.4) Generating Pods project Integrating client project -
Import the header files using the matching code for the programming language of your project:
-
For Swift projects:
// Swift import AgoraClassroomSDK_iOS -
For Objective-C projects:
// Objective-C import <AgoraClassroomSDK_iOS/AgoraClassroomSDK.h>
-
-
To launch the classroom in the education use-case, call AgoraClassroomSDK.launch. Sample code:
-
For Swift projects:
let launchConfig = AgoraEduLaunchConfig(userName: userName, // The user name userUuid: userUuid, // The user ID userRole: userRole, // User roles: 1 is teacher, 2 is student roomName: roomName, // The room name roomUuid: roomUuid, // The room ID roomType: roomType, // The room type, 0: One-to-one interactive teaching, 2: Big class, 4: Online interactive small class appId: appId, // The App ID token: token, // In a test environment, you can use a temporary Signaling token; in a production or a security environment, Agora strongly recommends using a server-generated Signaling token instead. startTime: nil, // The starting time of the class duration: nil, // The class duration region: region, // The area mediaOptions: mediaOptions, // Media stream related settings userProperties: nil) // User properties defined by the developer AgoraClassroomSDK.setDelegate(self) AgoraClassroomSDK.launch(launchConfig, success: launchSuccessBlock, failure: failureBlock) -
For Objective-C projects:
AgoraEduLaunchConfig *launchConfig = [[AgoraEduLaunchConfig alloc] initWithUserName:userName // The user name userUuid:userUuid // The user ID userRole:userRole // User roles: 1 is teacher, 2 is student roomName:roomName // The room name roomUuid:roomUuid // The room ID roomType:roomType // The room type, 0: One-to-one interactive teaching, 2: Big class, 4: Online interactive small class appId:appId // The App ID token:token // In a test environment, you can use a temporary Signaling token; in a production or security environment,Agora strongly recommends using a server-generated Signaling token instead. startTime:nil // The starting time of the class duration:nil // The class duration region:region // The area mediaOptions:mediaOptions // Media stream-related settings userProperties:nil]; // User properties defined by the developer [AgoraClassroomSDK setDelegate:self]; [AgoraClassroomSDK launch:launchConfig success:successBlock failure:failureBlock];
The sample code requires passing in
rtmToken. You can refer to Generate a Signaling token to learn what Signaling token is, how to get a temporary Signaling token for testing purposes, and how to generate a Signaling token from the server. In a production environment, to ensure security, you need to deploy and generate a Token on the server. TheuserIdpassed in the generated token must be consistent with theuserUuidparameter of thelaunchmethod. Otherwise, the generated token will be invalid. -
-
(Optional) Customize the display mode (bright/dark) and language (Chinese/English) of the interface for education use-case.
-
For Swift projects:
import AgoraUIBaseViews /* Import the `AgoraUIBaseViews` library. The library provides two variables for customizing display mode and language: agora_ui_mode and agora_ui_language.*/ agora_ui_mode = .agoraLight /* Set the interface display mode, which can be set to agoraLight or agoraDark. The default is agoraLight. */ agora_ui_language = "zh-Hans" /* Set the interface language, which can be set to "zh-Hans" or "en". If not set, the interface language follows the system language. */ -
For Objective-C projects:
/* Import the AgoraUIBaseViews library. The library provides two variables for customizing display mode and language: agora_ui_mode and agora_ui_language*/ #import <AgoraUIBaseViews/AgoraUIBaseView-Swift.h> agora_ui_mode = AgoraUIModeAgoraLight /* Set the interface display mode, which can be set to AgoraUIModeAgoraLight or AgoraUIModeAgoraDark. The default is AgoraUIModeAgoraLight.*/ agora_ui_language = @"zh-Hans" /* Set the interface language, which can be set to "zh-Hans" or "en". If not set, the interface language follows the system language.*/
-
-
Call the
AgoraClassroomSDK.exit()method to close the Flexible classroom in the education use-case.-
For Swift projects:
AgoraClassroomSDK.exit() -
For Objective-C projects:
[AgoraClassroomSDK exit];
-
Integrate and customize
To customize Flexible Classroom in the education use-case, download the source code from GitHub:
-
Run the following commands to clone CloudClass-iOS and apaas-extapp-ios projects locally. Switch to the branch of the version you need (the default is the latest version branch):
git clone https://github.com/AgoraIO-Community/CloudClass-iOS.gitgit clone https://github.com/AgoraIO-Community/apaas-extapp-ios.git -
Use
git remote add <shortname> <url>to add a remote repository forCloudClass-iOSandapaas-extapp-iospointing to your project repository, and push the required branches. -
Add the following dependencies in your project
Podfileto reference the librariesAgoraClassroomSDK_iOS.podspecandAgoraEduUI.podspecin the CloudClass-iOS project andAgoraWidgets.podspecin apaas-extapp-ios.# third-party libs pod 'SwifterSwift', '5.2.0' pod 'Masonry', '1.1.0' pod 'SDWebImage', '5.12.0' pod 'AgoraRtcEngine_Special_iOS', '3.7.2.133' pod 'Whiteboard', :git => 'https://github.com/netless-io/Whiteboard-iOS', :branch => 'effect-mixing' # open source libs pod 'AgoraClassroomSDK_iOS', '2.8.111' pod 'AgoraWidgets', '2.8.111' -
Enter the project directory in the terminal and run the
pod installcommand.
After the installation is completed, refer to Customize the classroom UI to understand the open source layer design ideas and modify the source code to customize the use-case.
Proctoring use-case
Flexible Classroom in the integrated proctoring use-case
To use the default UI of Flexible Classroom, take the following steps to add remote dependencies and integrate the whole Flexible Classroom through CocoaPods:
-
Open your project with Xcode and add the following code to the project's
Podfile:# third-party libs pod 'SwifterSwift', '5.2.0' pod 'Masonry', '1.1.0' pod 'SDWebImage', '5.12.0' pod 'AgoraRtcEngine_Special_iOS', '3.7.2.133' # open source libs pod 'AgoraProctorSDK', '1.0.2' -
Navigate into the project directory in the terminal and run
pod installto install the dependencies. For example, the following will be printed for v2.80.20:Analyzing dependencies Downloading dependencies Installing AgoraProctorSDK (1.0.0) Installing AgoraProctorUI (1.0.0) Installing AgoraEduCore (2.8.20) Installing AgoraLog (1.0.2) Installing AgoraMediaPlayer_iOS (1.3.0) Installing AgoraRtcEngine_iOS (3.7.2) Installing AgoraRtm_iOS (1.4.8) Installing AgoraUIBaseViews (2.8.0) Installing AgoraWidget (2.8.0) Installing AliyunOSSiOS (2.10.8) Installing Armin (1.1.0) Installing CocoaLumberjack (3.6.1) Installing Masonry (1.1.0) Installing Protobuf (3.17.0) Installing SDWebImage (5.12.0) Installing SSZipArchive (2.4.2) Installing SwifterSwift (5.2.0) Installing YYModel (1.0.4) Generating Pods project Integrating client project -
Import the header files using the matching code for the programming language of your project:
-
For Swift projects:
import AgoraProctorSDK -
For Objective-C projects:
#import <AgoraProctorSDK/AgoraProctorSDK.h>
-
-
To launch the classroom in the proctoring use-case, call AgoraProctorSDK.launch. Sample code:
-
For Swift projects:
let launchConfig = AgoraProctorLaunchConfig(userName: userName, // The user name userUuid: userUuid, // The user ID userRole: userRole, // The user roles roomName: roomName, // The room name roomUuid: roomUuid, // The room ID appId: appId, // The App ID token: token, // In a test environment, you can use a temporary Signaling token; in a production or a security environment, Agora strongly recommends using a server-generated Signaling token instead. region: region, // The area mediaOptions: mediaOptions, // Media stream related settings userProperties: nil) // User properties defined by the developer let proctor = AgoraProctorSDK(launchConfig, delegate: self) proctor.launch(success: successBlock, failure: failureBlock) -
For Objective-C projects:
AgoraProctorLaunchConfig *launchConfig = [[AgoraProctorLaunchConfig alloc] initWithUserName:userName // The user name userUuid:userUuid // The user ID userRole:userRole // User roles: 1 is teacher, 2 is student roomName:roomName // The room name roomUuid:roomUuid // The room ID appId:appId // The App ID token:token // In a test environment, you can use a temporary Signaling token; in a production or security environment,Agora region:region // The area mediaOptions:mediaOptions // Media stream-related settings userProperties:nil]; // User properties defined by the developer AgoraProctorSDK *proctor = [[AgoraProctorSDK alloc] init:launchConfig delegate:self]; [proctor launch:successBlock failure:failureBlock];
The sample code requires passing in
rtmToken. You can refer to Generate a Signaling token to learn what Signaling token is, how to get a temporary Signaling token for testing purposes, and how to generate a Signaling token from the server. In a production environment, to ensure security, you need to deploy and generate a Token on the server. TheuserIdpassed in the generated token must be consistent with theuserUuidparameter of thelaunchmethod. Otherwise, the generated token will be invalid. -
-
(Optional) Customize the display mode (bright/dark) and language (Chinese/English) of the interface for proctoring use-case.
-
For Swift projects:
import AgoraUIBaseViews /* Import the `AgoraUIBaseViews` library. The library provides two variables for customizing display mode and language: agora_ui_mode and agora_ui_language.*/ agora_ui_mode = .agoraLight /* Set the interface display mode, which can be set to agoraLight or agoraDark. The default is agoraLight. */ agora_ui_language = "zh-Hans" /* Set the interface language, which can be set to "zh-Hans" or "en". If not set, the interface language follows the system language. */ -
For Objective-C projects:
/* Import the AgoraUIBaseViews library. The library provides two variables for customizing display mode and language: agora_ui_mode and agora_ui_language*/ #import <AgoraUIBaseViews/AgoraUIBaseView-Swift.h> agora_ui_mode = AgoraUIModeAgoraLight /* Set the interface display mode, which can be set to AgoraUIModeAgoraLight or AgoraUIModeAgoraDark. The default is AgoraUIModeAgoraLight.*/ agora_ui_language = @"zh-Hans" /* Set the interface language, which can be set to "zh-Hans" or "en". If not set, the interface language follows the system language.*/
-
-
To close the Flexible Classroom in a proctoring scenario, release the
AgoraProctorSDKobject:-
For Objective-C projects:
proctorSDK = nil; -
For Swift projects:
proctorSDK = nil
-
Integrate and customize
To customize Flexible Classroom in the proctoring use-case, download the source code from GitHub:
-
Run the following commands to clone proctor-ios project locally. Switch to the branch of the version you need (the default is the latest version branch):
git clone https://github.com/AgoraIO-Community/proctor-ios.git -
Use
git remote add <shortname> <url>to add the remoteproctor-iosrepository pointing to your project repository, and push the required branches. -
Add the following dependencies in your project
Podfileto reference theAgoraProctorSDK.podspecandAgoraProctorUI.podspeclibraries.# third-party libs pod 'SwifterSwift', '5.2.0' pod 'Masonry', '1.1.0' pod 'SDWebImage', '5.12.0' pod 'AgoraRtcEngine_Special_iOS', '3.7.2.133' # open source libs pod 'AgoraProctorSDK', '1.0.2' -
Enter the project directory in the terminal and run the
pod installcommand.After the installation is completed, refer to Customize the classroom UI to understand the open source layer design ideas and modify the source code to customize the use-case.
Considerations
After integration, add the following keys to your project's Info.plist file to request the necessary permissions for running Flexible Classroom:
- Privacy – Camera Usage Description
- Privacy – Microphone Usage Description
- Privacy – Photo Library Additions Usage Description
- Privacy – Photo Library Usage Description
In Xcode 14.0 and later:
-
If you see the
AgoraEduUI-AgoraEduUIbundle signature error (bundleRequire Signature), add the following to yourPodfile:post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| if target.respond_to?(:product_type) && target.product_type == "com.apple.product-type.bundle" config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' end end end end -
If you see the
Symbol not found: (__ZN5swift34swift50override_conformsToProtocol...)error inArmin.framework/Armin, add the following to yourPodfile:low_version_target_names = ["Armin", "YYModel", "Masonry", "NTLBridge", "CocoaLumberjack", "AliyunOSSiOS"] post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| if low_version_target_names.include?(target.name) config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0' end end end end
For more information, see Apple's privacy manifest documentation.
