文档

iOS端集成

更新时间:

本文介绍了互动课堂场景iOS端样板间的集成方法。

前提条件

  • 设备类型:支持iPhone和iPad所有型号。

  • CPU架构:支持iOS真机armv7、arm64架构,不支持模拟器i386、X86_64架构。

  • 系统版本:支持iOS 10.0及以上版本。

  • 其他:不支持bitcode,不支持屏幕旋转。

集成步骤

第一步:添加SDK依赖

SDK依赖可基于CocoaPods添加或基于本地Framework依赖方式添加,推荐使用基于CocoaPods添加的方式。

  • 方式1:基于CocoaPods添加SDK依赖(推荐)

    在已有Xcode工程的Podfile文件中增加代码,需要添加的代码有:

      #阿里云低代码音视频工厂总入口库
      pod 'AliInteractiveRoomBundle', '1.5.1'
    
      #阿里云低代码音视频工厂依赖的三方库
      pod 'Masonry'
      pod 'MJRefresh'
      pod 'LEEAlert'
      
      #阿里云低代码音视频工厂互动课堂样板间库
      pod 'AliStandardClassroomBundle', '1.5.1'
    
      #阿里云低代码音视频工厂观众拉流相关库
      pod 'AliInteractiveVideoPlayerCore', '1.5.1'
      pod 'AliPlayerSDK_iOS', '5.4.3.0-15301379'
        
      #阿里云低代码音视频工厂RTC相关库
      pod 'AliInteractiveRTCCore', '1.5.1'
      pod 'AliRTCSdk', '2.5.3'
        
      #阿里云低代码音视频工厂白板能力相关库
      pod 'AliInteractiveWhiteBoardCore', '1.5.1'
    
      #阿里云低代码音视频工厂文档能力相关库
      pod 'AliInteractiveDocumentCore', '1.5.1'
  • 方式2:基于本地Framework添加SDK依赖

    1. 下载并解压SDK。

      打开低代码音视频工厂控制台>应用管理 > 样板间集成,下载最新iOS端SDK。

      解压之后,文件结构如下图所示:

      课堂样板间sdk
    2. 在Xcode工程TARGETSGeneral页签下,在Frameworks, Libraries, and Embedded Content区域中添加以下framework,并修改对应的Embed属性。

      framework集成
    3. 把资源文件AliInteractiveWhiteBoardCoreResource.xcassets和AliStandardClassroomResource.bundle添加到自己的工程目录下(与系统Assets.xcassets平级)。

      iOS相关文件
    4. 增加pod依赖Masonry开源库。请在已有的Podfile中增加如下一行:

      pod 'Masonry'
      pod 'MJRefresh'
      pod 'LEEAlert'

第二步:代码接入

此处以在ViewController中集成样板间为例,实际请以自己业务为准。

样板间有iPhone样式和iPad样式,请根据实际需要添加对应的代码。

iPhone学生端样板间:

#import "ViewController.h"
#import <AliStandardClassroomBundle/AliStandardClassroomBundle.h>

@interface ViewController ()<ASCRBStudentViewController4PhoneProtocolDelegate>

@property (nonatomic, strong) ASCRBAppInitConfig* appConfig;
@property (nonatomic, strong) id<ASCRBStudentViewController4PhoneProtocol> studentVC4Phone;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
        
    //******** 初始化相关配置 ********//
    ASCRBAppInitConfig* appInitConfig = [[ASCRBAppInitConfig alloc]init];
    appInitConfig.appID = [NSString stringWithFormat:@"%@", @"xxxxxx"];    // 在阿里云控制台开通互动直播后获取;
    appInitConfig.appKey = [NSString stringWithFormat:@"%@", @"xxxxxxxxxxxxxxxxxxx"]; // 在阿里云控制台开通互动直播后获取;
    appInitConfig.appServerUrl = [NSString stringWithFormat:@"%@", @"xxxxxxxxxxx"];   // AppServer部署好之后会获得;
    appInitConfig.appServerSignSecret = [NSString stringWithFormat:@"%@", @"xxxxxxxx"];  // 在阿里云控制台开通互动直播后获取;
    appInitConfig.userID = @"xxxx";   // 自定义用户id,必须是英文字母或者阿拉伯数字或者二者组合
    appInitConfig.userNick = @"xxxxx的昵称"; // 自定义用户昵称,必传
    self.appConfig = appInitConfig;
    
    ASCRBClassInitConfig* classInitConfig = [[ASCRBClassInitConfig alloc] init];
    classInitConfig.role = ASCRBUserRoleStudent; // 学生    
    classInitConfig.classID = @"xxxxxxx";   // 需要进入的课程ID,老师侧传空则会创建课程
    classInitConfig.classTitle = @"xxxxx"; // 自定义课程名称
    
    //******** 创建对应的vc ********//
    // 获取vc后,先进行setup,成功后再push对应vc
    self.studentVC4Phone = [[ASCRBClassroomManager sharedInstance] createStudentVC4PhoneWithAppInitConfig:self.appConfig classInitConfig:classInitConfig];
    self.studentVC4Phone.delegate = self;
    [self.studentVC4Phone setup];
}

// 在对应的setup成功事件中push创建的vc
#pragma mark  - ASCRBStudentViewController4PhoneProtocolDelegate
- (void)onASCRBStudentViewController4Phone:(nonnull id<ASCRBStudentViewController4PhoneProtocol>)classroomVC classroomEvent:(ASCRBClassroomEvent)classroomEvent info:(nonnull NSDictionary *)info {
    switch (classroomEvent) {
        case ASCRBClassroomEventSetupSucceed:{
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.navigationController pushViewController:self.studentVC4Phone animated:YES];
            });
        }
            break;
        case ASCRBClassroomEventLeaveClassroom:
            self.studentVC4Phone = nil;
            break;
            
        default:
            break;
    }
}

- (void) onASCRBStudentViewController4Phone:(id<ASCRBStudentViewController4PhoneProtocol>)classroomVC classroomError:(ASCRBClassroomError)classroomError withErrorMessage:(NSString*)errorMessage {
    switch (classroomError) {
        case ASCRBClassroomErrorFailedToSetup:
            break;
            
        default:
            break;
    }
}

@end

iPad学生端样板间:

#import "ViewController.h"
#import <AliStandardClassroomBundle/AliStandardClassroomBundle.h>

@interface ViewController () <ASCRBStudentViewController4PadProtocolDelegate>

@property (nonatomic, strong) ASCRBAppInitConfig* appConfig;
@property (nonatomic, strong) id<ASCRBStudentViewController4PadProtocol> studentVC4Pad;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
        
    //******** 初始化相关配置 ********//
    ASCRBAppInitConfig* appInitConfig = [[ASCRBAppInitConfig alloc]init];
    appInitConfig.appID = [NSString stringWithFormat:@"%@", @"xxxxxx"];    // 在阿里云控制台开通互动直播后获取;
    appInitConfig.appKey = [NSString stringWithFormat:@"%@", @"xxxxxxxxxxxxxxxxxxx"]; // 在阿里云控制台开通互动直播后获取;
    appInitConfig.appServerUrl = [NSString stringWithFormat:@"%@", @"xxxxxxxxxxx"];   // AppServer部署好之后会获得;
    appInitConfig.appServerSignSecret = [NSString stringWithFormat:@"%@", @"xxxxxxxx"];  // 在阿里云控制台开通互动直播后获取;
    appInitConfig.userID = @"xxxx";   // 自定义用户id,必须是英文字母或者阿拉伯数字或者二者组合
    appInitConfig.userNick = @"xxxxx的昵称"; // 自定义用户昵称,必传
    self.appConfig = appInitConfig;
    
    ASCRBClassInitConfig* classInitConfig = [[ASCRBClassInitConfig alloc] init];
    classInitConfig.role = ASCRBUserRoleStudent; // 学生    
    classInitConfig.classID = @"xxxxxxx";   // 需要进入的课程ID,老师侧传空则会创建课程
    classInitConfig.classTitle = @"xxxxx"; // 自定义课程名称
    
    //******** 创建对应的vc ********//        
    // 获取vc后,先进行setup,成功后再push对应vc
    self.studentVC4Pad = [[ASCRBClassroomManager sharedInstance] createStudentVC4PadWithAppInitConfig:self.appConfig classInitConfig:classInitConfig];
    self.studentVC4Pad.delegate = self;
    [self.studentVC4Pad setup];
}

// 在对应的setup成功事件中push创建的vc
#pragma mark  - ASCRBStudentViewController4PadProtocolDelegate
- (void)onASCRBStudentViewController4Pad:(nonnull id<ASCRBStudentViewController4PadProtocol>)classroomVC classroomEvent:(ASCRBClassroomEvent)classroomEvent info:(nonnull NSDictionary *)info {
    switch (classroomEvent) {
        case ASCRBClassroomEventSetupSucceed:{
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.navigationController pushViewController:self.studentVC4Pad animated:YES];
            });
        }
            break;
        case ASCRBClassroomEventLeaveClassroom:
            self.studentVC4Pad = nil;
            break;
            
        default:
            break;
    }
}

- (void) onASCRBStudentViewController4Pad:(id<ASCRBStudentViewController4PadProtocol>)classroomVC classroomError:(ASCRBClassroomError)classroomError withErrorMessage:(NSString*)errorMessage {
    switch (classroomError) {
        case ASCRBClassroomErrorFailedToSetup:
            break;
            
        default:
            break;
    }
}

@end

iPad老师端样板间:

#import "ViewController.h"
#import <AliStandardClassroomBundle/AliStandardClassroomBundle.h>

@interface ViewController () <ASCRBTeacherViewController4PadProtocolDelegate>

@property (nonatomic, strong) ASCRBAppInitConfig* appConfig;
@property (nonatomic, strong) id<ASCRBTeacherViewController4PadProtocol> teacherVC4Pad;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
        
    //******** 初始化相关配置 ********//
    ASCRBAppInitConfig* appInitConfig = [[ASCRBAppInitConfig alloc]init];
    appInitConfig.appID = [NSString stringWithFormat:@"%@", @"xxxxxx"];    // 在阿里云控制台开通互动直播后获取;
    appInitConfig.appKey = [NSString stringWithFormat:@"%@", @"xxxxxxxxxxxxxxxxxxx"]; // 在阿里云控制台开通互动直播后获取;
    appInitConfig.appServerUrl = [NSString stringWithFormat:@"%@", @"xxxxxxxxxxx"];   // AppServer部署好之后会获得;
    appInitConfig.appServerSignSecret = [NSString stringWithFormat:@"%@", @"xxxxxxxx"];  // 在阿里云控制台开通互动直播后获取;
    appInitConfig.userID = @"xxxx";   // 自定义用户id,必须是英文字母或者阿拉伯数字或者二者组合
    appInitConfig.userNick = @"xxxxx的昵称"; // 自定义用户昵称,必传
    self.appConfig = appInitConfig;
    
    ASCRBClassInitConfig* classInitConfig = [[ASCRBClassInitConfig alloc] init];
    classInitConfig.role = ASCRBUserRoleTeacher; // 老师
    classInitConfig.classID = @"";   // 需要进入的课程ID,老师侧传空则会创建课程
    classInitConfig.classTitle = @"xxxxx"; // 自定义课程名称
    
    //******** 创建对应的vc ********//
    // 获取vc后,先进行setup,成功后再push对应vc
    self.teacherVC4Pad = [[ASCRBClassroomManager sharedInstance] createTeacherVC4PadWithAppInitConfig:self.appConfig classInitConfig:classInitConfig];
    self.teacherVC4Pad.delegate = self;
    [self.teacherVC4Pad setup];
}

// 在对应的setup成功事件中push创建的vc
#pragma mark  - ASCRBTeacherViewController4PadProtocolDelegate
- (void)onASCRBTeacherViewController4Pad:(nonnull id<ASCRBTeacherViewController4PadProtocol>)classroomVC classroomEvent:(ASCRBClassroomEvent)classroomEvent info:(nonnull NSDictionary *)info {
    switch (classroomEvent) {
        case ASCRBClassroomEventSetupSucceed:{
            NSLog(@"classID:%@", [info valueForKey:@"classID"]);
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.navigationController pushViewController:self.teacherVC4Pad animated:YES];
            });
        }
            break;
        case ASCRBClassroomEventLeaveClassroom:
            self.teacherVC4Pad = nil;
            break;
            
        default:
            break;
    }
}

- (void) onASCRBTeacherViewController4Pad:(id<ASCRBTeacherViewController4PadProtocol>)classroomVC classroomError:(ASCRBClassroomError)classroomError withErrorMessage:(NSString*)errorMessage {
    switch (classroomError) {
        case ASCRBClassroomErrorFailedToSetup:
            break;
            
        default:
            break;
    }
}

@end
  • 本页导读 (1)
文档反馈