Skip to content

Ks3SdkDoc/QYLiveSDK_iOS

Repository files navigation

QYLiveSDK

##阅读对象 本文档面向所有使用该SDK的开发人员, 测试人员等, 要求读者具有一定的iOS编程开发经验. ##QYLiveSDK简介 QYLiveSDK(以下简称SDK) 是金山云为广大iOS开发者提供的集视频推流播放为一体的,直播/播放组件。SDK提供了可配置化的UI支持。提供了播放列表,直播间,送礼,关注,主播信息简介等UI实现,开发者集成之后,可一键进入直播,实现直播功能

SDK业务流程

业务流程图

##集成环境

  • 1、目前SDK只支持iOS8.0以上。
  • 2、SDK目前暂时不支持bitcode。请在xcodeproj-->BuildSetting-->Build Options 的Enable Bitcode 设置成NO。
  • 3、SDK目前暂时不支持HTPPS,请在工程的info.plist中添加App Transport Security Settings,并在之下添加Allow Arbitrary Loads,并设置成YES。

##集成步骤

  • 1、使用CocoaPods 导入 SDK. pod 'QYLiveSDK', '~> 1.0.0',之后pod install,成功导入之后即可使用。
  • 2、直接下载SDK手动导入

##添加依赖库 SDK中引入了一些常用的第三方库,如果开发者的工程中包含以下的某个第三方库,不必要重复导入,如果没有请导入。 以下是需要依赖的第三方库列表:

  • AFNetworking
  • SDWebImage
  • Masonry
  • RongCloudIMLib
  • MJRefresh
  • KSYGPULive_iOS
  • SSZipArchive
  • FMDB
  • pop
  • MOBFoundation

这些库可以通过CocoaPods导入,也可以下载下来,手动导入SDK

##快速集成 ###1、关键类说明

  • QYLiveEngine :SDK 核心类,提供了用户调用SDK的接口。
  • QYTypeDef :宏定义文件
  • QYUserProfile:用户信息类

###2、SDK启用 在需要使用SDK的类中,import相关的头文件

#import <QYLiveSDK/QYLiveSDK.h>

  • 开发者从金山云获取AppKey,AppKey用于标识用户身份,必填。
  • andObject所带参数是字典类型,可动态配置SDK的状态,传空是默认状态。
  • 用AppKey初始化 SDK,开发者APP中只初始化一次token就可以。
[[QYLiveEngine sharedInstance] initWithAppKey:QYLIVE_AK andObject:nil]
  • 初始化AppKey成功之后,调用connect方法,连接金山云Server,获取openid
  • 如果是登录状态,传入token值。如果传空是未登录状态,用户是游客状态。
    [[QYLiveEngine sharedInstance] connectWithToken:nil :^(QYErrCode code, NSInteger what, NSString * _Nullable extra) {
        
        if (code == QYShareSuccess) {
        
        }else {
        
            NSLog(@"connect error is %@",extra);
        }
    }];


  • connect成功之后,在connect的成功回调中同步用户信息到金山云Server
    [[QYLiveEngine sharedInstance] connectWithToke:nil :^(QYErrCode code, NSInteger what, NSString * _Nullable extra) {
        
        if (code == QYShareSuccess) {
        
            QYUserProfile *userProfile = [[QYUserProfile alloc] init];
            userProfile.uid = @"asdfghjkl";
            userProfile.nickName = @"傲娇盟主";
            userProfile.profileIcon = @"http://test-huzilong.kss.ksyun.com/ObjectPrefix/201606071506258791";

            [[QYLiveEngine sharedInstance] syncUserProfile:userProfile error:^(QYErrCode code, NSInteger what, NSString * _Nullable extra) {
                
                if (code != QYShareSuccess) {
                    
                    NSLog(@"syncUserProfile error is %@",extra);

                }
            }];
        }else {
        
            NSLog(@"connect error is %@",extra);
        }
    }];


  • 在需要进入直播页面的时候调用enterScene方法,一键进入直播列表页/充值页
- (void)enterLive:(UIButton *)button
{
    NSDictionary *context = nil;
    if (button.tag == 99) {
        
        context = @{kQYLiveEngineViewController : @(QYReChargeViewController)};
        
    }else if (button.tag == 98){
    
        context = @{kQYLiveEngineViewController : @(QYMainViewController)};

    }
    UIViewController *liveViewController = [[QYLiveEngine sharedInstance] enterScene:context];
    UINavigationController *navigationVc = [[UINavigationController alloc] initWithRootViewController:liveViewController];
    [self presentViewController:navigationVc animated:YES completion:nil];

    
}


  • 若按照以上步骤集成仍然出现问题,请及时联系我们,我们将竭诚为您服务!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published