iOS 接入说明文档

接入YXT SDK 首先遵循以下步骤:

  • 配置 SDK 集成环境
  • 按照以下接入文档集成代码

    SDK 集成环境配置

    开发与运行环境

  • Xcode
  • iOS 8.0 及以上版本

    Cocoapods 快速集成

1、 使用 CocoaPods 导入YXT SDK

1、请参见Cocoapods接入方式(https://cocoapods.org/

  1. pod YXTSDK’, ‘~> 1.7

2、开发人员请点击SDK下载,下载对应的Demo进行体验。

2、声明SDK需要的权限

SDK集成步骤

1、AppDelegate中配置代码

  1. [YXTHelper getInstance].environment = YXTEnvironmentDevelopment;
  2. [[YXTHelper getInstance] appLauchWithOption:launchOptions];

2、打开播放器

  1. [YXTHelper getInstance].closePreview = NO; // 是否关闭预览界面(YES:关闭,NO:打开。默认NO)
  2. [YXTHelper getInstance].hideNavBar = YES; // 是否显示导航栏(YES:隐藏,NO:显示。默认NO)
  3. [[YXTHelper getInstance] setBeforeViewController:当前界面ViewController];
  4. YXTModel *model = [[YXTModel alloc] init];
  5. model.id = @"文件id";
  6. model.type = @"文件类型";
  7. model.cid = @"课程ID";
  8. model.pid = @"学习计划ID";
  9. model.cid = @"课程ID";
  10. model.genscore = @"是否产生学分记录";
  11. model.allowdown = @"是否允许下载";
  12. model.url = @"优先使用这个url播放 为空,由api获取播放地址";
  13. model.workshopId = @"专题ID";
  14. model.token = @"用户凭据";
  15. model.userId = @"用户唯一标识";
  16. [[YXTHelper getInstance] openPlayWithModel:model];

3、打开滑动播放器

  1. [[YXTHelper getInstance] setBeforeViewController:当前界面ViewController];
  2. NSString * str = [NSString decodeString:jsModel.param];
  3. NSDictionary * dic = [str mj_JSONObject];
  4. YXTModel *model = [YXTModel mj_objectWithKeyValues:dic];
  5. [[YXTHelper getInstance] loginYxtModel:model];
  6. [[YXTHelper getInstance] openQuickKngWithModel:dic];

YXTModel 格式参考

4、下载配置

  1. [[YXTHelper getInstance] setBeforeViewController:当前界面ViewController];
  2. [[YXTHelper getInstance] openDownloadList];

5、回调协议

  1. [YXTHelper getInstance].delegate = self; // 实现代理,并添加代理 YXTDelegate
  2. // 相关协议 查看 YXTHelper 里 YXTDelegate

6、处理分享协议

  1. [YXTHelper getInstance].shareClickBlock = ^(NSDictionary *dic) {
  2. NSString *title = dic[@"title"];
  3. NSString *summary = dic[@"desc"];
  4. NSString *shareUrl = dic[@"shareUrl"];
  5. NSString *shareImagePath = dic[@"shareImg"];
  6. /*
  7. 处理分享参数
  8. */
  9. };