This page introduces how to add Flexible Classroom to your iOS app.
Flexible Classroom contains the following libraries:
AgoraClassroomSDK
: The glue code that connects AgoraEduContext
, AgoraEduUI
and AgoraEduCore
. AgoraClassroomSDK
is an open-sourced project and released on GitHub and CocoaPods.AgoraEduUI
: This library contains the code for the UI and also includes all the texts and resource files used by Flexible Classroom. AgoraEduCore
provides this library with the functionality and data in Flexible Classroom through AgoraEduContext
. AgoraEduUI
is an open-sourced project and released on GitHub and CocoaPods.AgoraEduContext
: This library defines context protocols and data structure. AgoraEduContext
is an open-sourced project and released on GitHub and CocoaPods.AgoraEduCore
: This library provides the capabilities and data in Flexible Classroom, and follows the protocols defined in AgoraEduContext
. AgoraEduCore
is a closed-source library and released on CocoaPods as a binary package.Widget
: This library provides independent plugins that include both interfaces and functions. These plugins are injected into Flexible Classroom by AgoraClassroomSDK
. Widgets can communicate with each other.The following figure shows the structure of Flexible Classroom.
If you 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
:
pod 'OpenSSL-Universal', '1.0.2.17'
pod 'Protobuf', '3.17.0'
pod 'CocoaLumberjack', '3.6.1'
pod 'AliyunOSSiOS', '2.10.8'
pod 'Armin', '1.0.9'
pod 'Alamofire', '4.7.3'
pod 'SSZipArchive', '2.4.2'
pod 'SwifterSwift', '5.2.0'
pod 'Masonry', '1.1.0'
pod 'SDWebImage', '5.12.0'
pod 'WHToast', '0.0.7'
pod 'FLAnimatedImage', '3.8.6'
# Agora libs
pod 'AgoraRtm_iOS', '1.4.8'
pod 'Whiteboard', '2.15.18'
pod 'AgoraRtcEngine_iOS', '3.4.6'
pod 'HyphenateChat', '3.8.6'
# Open-source libs
pod 'AgoraClassroomSDK_iOS', '2.1.0'
Below is an example:
Navigate into the project directory in the terminal and run pod install
to install the dependencies, as the following picture shows:
Import the header files with the following code:
// Swift
import AgoraClassroomSDK_iOS
// Objective-C
import <AgoraClassroomSDK_iOS/AgoraClassroomSDK.h>
To launch the classroom, call AgoraClassroomSDK.launch. Sample code:
// Swift
let appId = Your AppId /* Pass your App ID */
let rtmToken = Your rtmToken /* Pass your RTM Token */
let userUuid = Your userId
let launchConfig = AgoraEduLaunchConfig(userName: user /* The user name */,
userUuid: userUuid /* The user ID */,
userRole: .student /* The user role */,
roomName: room /* The room name */,
roomUuid: roomUuid /* The room ID */,
roomType: roomStyle /* The room type */,
appId: appId,
token: rtmToken /* In a test environment, you can use a temporary RTM token; in a production or security environment, Agora strongly recommends that you use a server-generated RTM token. */,
startTime: nil /* The class start time */,
duration: NSNumber(value: duration) /* The class duration */,
region: region.eduType /* The region */,
mediaOptions: nil /* Media options */,
userProperties: nil)
AgoraClassroomSDK.setDelegate(self)
AgoraClassroomSDK.launch(launchConfig,
success: launchSuccessBlock,
failure: failureBlock)
// Objective-C
AgoraEduMediaEncryptionConfig *config = [[AgoraEduMediaEncryptionConfig alloc] initWithMode:0 key:nil];
AgoraEduMediaOptions *media = [[AgoraEduMediaOptions alloc] initWithEncryptionConfig:config videoEncoderConfig:nil latencyLevel:2 videoState:1 audioState:1];
AgoraEduLaunchConfig *launchConfig =
[[AgoraEduLaunchConfig alloc] initWithUserName: userName /* The user name */
userUuid: userUuid /* The user ID */
userRole: /* The user role */
roomName:@"Room name"
roomUuid:@"Room ID"
roomType:4 /* The room type */
appId:@"AppId"
token:@"Your RTM Token" /* In a test environment, you can use a temporary RTM token; in a production or security environment, Agora strongly recommends that you use a server-generated RTM token. */
startTime:nil /* The class start time */
duration:[NSNumber numberWithInt:7200] /* The class duration */
region:0 /* The region */
mediaOptions:media /* Media options */
userProperties:nil];
[AgoraClassroomSDK launch:launchConfig success:^{
NSLog(@"success");
} failure:^(NSError * _Nonnull err) {
NSLog(@"failure");
}];
The sample code requires passing in rtmToken
. You can refer to Generate an RTM token to learn what is RTM token, how to get a temporary RTM token for testing purpose, and how to generate an RTM token from the server.
AgoraEduCore
is a binary Swift framework. Since Apple‘s support for binary Swift frameworks is not strong enough, to avoid compatibility issues, Agora adds an OC wapper. If you use import AgoraEduCore
to import AgoraEduCore
, you may encounter an error saying that the Swift version is not compatible. Solve the error in the following ways:
OC: Use #import <AgoraEduCorePuppet/AgoraEduCoreWrapper.h>
to import AgoraEduCore
, and replace the AgoraEduCore
class with the AgoraEduCorePuppet
class.
Swift: Use import AgoraEduCorePuppet
to import AgoraEduCore
, and replace the AgoraEduCore
class with the AgoraEduCorePuppet
class.
If your project is an OC project, you need to add User-Defined Setting in Build Settings: