Latest 1.0.1
Homepage https://github.com/camsgear/APPGear-iOS
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

集成

  • 手动集成
  • CocoaPod (即将支持)

    手动集成

    1. 下载APPGear-iOS SDK 下载地址

    2. 接入APPGear-iOS SDK

  • 将APPGear-iOS SDK添加到工程
  • 添加项目配置
  • Build Settings -> Linking -> Ohter linker Flags 中添加-ObjC
  • Build Settings -> Architectures -> Architectures中添加armv7s
  • Build Settings -> Architectures -> Build Active Architecture Only 改为NO

    3. 加入依赖库

  • Build phases -> Link Binary With Libraries 中添加 libresolv.9.tbd
  • Build phases -> Link Binary With Libraries 中添加 APPGear-iOS.framework

    4. 初始化

  • AppDelegate.m中添加 #import <APPGear/APPGear.h>
  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加一下代码:

    (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ///  配置API信息
    [CDAAPIManager setUpConfiguration];
    
    ///  配置用户信息
    [CDAUserManager setUpUserConfiguration];
    
    return YES;
    }

功能模块

用户模块

获取手机验证码

函数定义
- (void)getVerifyCodeWithPhoneNumber:(NSString *)phoneNumber
                                type:(NSString *)type 
                             success:(UserSuccessBlock)success 
                             failure:(UserFailureBlock)failure
参数说明
  • phoneNumber – 手机号码
  • type – 验证类型 (signin:登录, signup:注册, signin_signup:登录注册通用)
  • success – 成功回调
  • failure – 失败回调
    示例
    [[CDAUserManager sharedManager]getVerifyCodeWithPhoneNumber:self.phoneNumber.text
                                                       type:@"signin_signup" 
                                                    success:^(id result) {
    [SVProgressHUD showSuccessWithStatus:@"获取验证码成功,请注意查看短信"];
    } failure:^(NSError *error) {
    NSLog(@"%@",error);
    [SVProgressHUD showErrorWithStatus:@"获取验证失败,请确认手机号书否输入正确"];
    }];

登录

函数定义
- (void)signinOrSignup:(NSString *)phone 
      verificationCode:(NSString *)code
               success:(UserSuccessBlock)success 
               failure:(UserFailureBlock)failure
参数说明
  • phone – 手机号码
  • code – 手机验证码
  • success – 成功回调
  • failure – 失败回调
    示例
    [[CDAUserManager sharedManager]signinOrSignup:self.phoneNumber.text 
                             verificationCode:self.verificationCode.text
                                      success:^(id result) {
    [SVProgressHUD showSuccessWithStatus:@"登录成功"];
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"登录失败,请确认手机号和验证码是否输入正确"];
    }];

    注销

    函数定义
  • (void)signOut: (UserSuccessBlock)success failure: (UserFailureBlock)failure;
    
    ##### 参数说明
  • success – 成功回调
  • failure – 失败回调
    示例
  • (IBAction)clickOnTheExitTheLogInButton:(id)sender {
    [[CDAUserManager sharedManager]signOut:^(id result) {
    [SVProgressHUD showSuccessWithStatus:@"注销成功"];
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"注销失败"];
    }];
    }

    
    ---

视频模块

获取视频数据

函数定义
- (void) getLatestVideos: (APISuccessBlock)success failure:(APIFailureBlock)failure;
参数说明
  • success – 成功回调
  • failure – 失败回调
    示例
    //block返回的result已经是转过模型的CDAVideo对象,可直接使用
    [[CDAAPIManager sharedManager]getLatestVideos:^(NSArray *result) {
    [self.videos addObjectsFromArray:result];
    [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"加载了%ld条数据",(unsigned long)result.count]];
    NSLog(@"--视频数据:%@",result);
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"加载失败"];
    }];

下拉获取最新数据

函数定义
- (void) getVideosBefore:(NSString *)videoId 
                  UserId:(NSString *)userId 
                 success:(APISuccessBlock)success 
                 failure:(APIFailureBlock)failure
参数说明
  • videoId – 当前列表的第一条video数据的id
  • userId – 用户id为想获取视频的用户id, nil则获取广场数据,下同
  • success – 成功回调
  • failure – 失败回调
    示例
    CDAVideo *firstVideo = [self.videos firstObject];
    //tips: userid区分 获取广场数据,还是个人数据
    [[CDAAPIManager sharedManager] getVideosBefore:firstVideo.id UserId:nil success:^(id result) {
    NSLog(@"--下拉视频数据:%@",result);
    } failure:^(NSError *error) {
    }];

    上拉获取更多视频数据

    函数定义
  • (void) getVideosAfter:(NSString )videoId
    UserId:(NSString
    )userId
    success:(APISuccessBlock)success
    failure:(APIFailureBlock)failure;

    
    ##### 参数说明
  • videoId – 当前列表的最后一条video数据的id
  • userId – 用户id
  • success – 成功回调
  • failure – 失败回调
    示例
    CDAVideo *lastVideo = self.videos.lastObject;
    //tips: userid区分 获取广场数据,还是个人数据
    [[CDAAPIManager sharedManager]getVideosAfter:lastVideo.id UserId:nil success:^(id result) {
    NSLog(@"--上拉视频数据:%@",result);
    } failure:^(NSError *error) {
    }];

    发布视频

    函数定义
  • (void) releaseVideoByLocalMedia:(CDALocalMedia )localMedia
    videoCoverImage:(UIImage
    )image
    upLoadProgress:(APIProgressBlock)progress
    success:(APISuccessBlock)success
    failure:(APIFailureBlock)failure;

    
    ##### 参数说明
  • localMedia – 待上传的视频对象
  • image – 视频封面,可为空,为空则取视频第一帧为封面
  • progress – Progress回调
  • success – 成功回调
  • failure – 失败回调
    示例
  • (IBAction)clickPostVideo:(id)sender {
    CDALocalMedia localMedia = [[CDALocalMedia alloc] init];
    // localMedia.name = media.name;
    // localMedia.relativeMediaUrl = relativeVideoDestination;
    // localMedia.relativethumbnailUrl = relativeThumbnailDestination;
    // localMedia.id = uuid;
    // localMedia.createdAt = [NSDate date];
    // localMedia.size = media.size;
    // localMedia.duration = media.duration;
    // localMedia.width = media.width;
    // localMedia.height = media.height;
    // localMedia.mediaType = media.mediaType;
    // localMedia.isPicture = picture;
    [[CDAAPIManager sharedManager]releaseVideoByLocalMedia:localMedia
    videoCoverImage:nil
    upLoadProgress:^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
    float percent = 0.8 + 0.2
    totalByteSent / totalBytesExpectedToSend;
    [SVProgressHUD showProgress:percent];
    } success:^(id result) {
    [SVProgressHUD showSuccessWithStatus:@"发布成功"];
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"发布失败"];
    }];
    }

    
    ---

直播模块

发布直播

函数定义
- (void) createEvent:(CDAEvent *)event 
         withChannel:(CDAChannel *)channel 
             success:(APISuccessBlock)success 
             failure:(APIFailureBlock)failure;
参数说明
  • event – 带创建的直播event对象
  • channel – 带创建的直播channel对象
  • success – 成功回调
  • failure – 失败回调
    示例
  • (IBAction)clickCreateLive:(id)sender {
    //1.上传直播封面
    UIImage coverImage = [UIImage imageNamed:@"cover"];
    NSData
    imageData = UIImageJPEGRepresentation(coverImage, 1.0);
    NSString uuid = [[NSUUID UUID] UUIDString];
    [[CDAAPIManager sharedManager]uploadData:imageData
    UUID:uuid
    withType:@"covers"
    withProgress:^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
    } success:^(id result) {
    //2.创建Event
    CDAEvent
    event = [[CDAEvent alloc] init];
    event.title = @"直播测试";
    event.subTitle = @"直播测试";
    event.eventDescription = @"直播测试";
    event.tags = @[];
    event.coverPath = result;

    //2.1 创建channel
    CDAChannel *channel = [[CDAChannel alloc] init];
    channel.videoType = @"设备deviceType";//按实际情况填写
    channel.camdoraMediaInfo = [CDACamdoraMediaInfo camdoraMediaInfoWithString:@"设备DeviceMode"];//按实际情况填写
    channel.stream = [[CDAStream alloc] init];
    channel.stream.serialNumber = @"设备sn号";//按实际情况填写
    channel.coverPath = result;

    //3.根据event 和channel 创建直播
    [[CDAAPIManager sharedManager]createEvent:event withChannel:channel success:^(id result) {
    //3.1 取到event和chann
    CDAEvent event = result[@"event"];
    CDAChannel
    channel = result[@"channle"];
    //3.2判断channel有没有值
    if (channel) {
    //3.3取出RTMPURL
    NSString rtmpURL = channel.stream.rtmpPushURL;
    //4.给设备设置RTMP推流地址
    //5.开始直播
    }
    } failure:^(NSError
    error) {
    [SVProgressHUD showErrorWithStatus:@"创建失败,缺少相机参数"];
    }];
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"上传封面失败"];
    }];
    }

    
    ---

获取直播数据

函数定义
- (void) getLatestEvents:(APISuccessBlock)success failure:(APIFailureBlock)failure;
参数说明
  • success – 成功回调
  • failure – 失败回调
    示例
    //block返回的result已经是转过模型的CDAEvent对象,可直接使用
    [[CDAAPIManager sharedManager]getLatestEvents:^(NSArray *result) {
    [self.events addObjectsFromArray:result];
    [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"加载了%ld条数据",(unsigned long)result.count]];
    NSLog(@"--直播数据:%@",result);
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"加载失败"];
    }];

    下拉获取最新直播数据

    函数定义
  • (void) getEventsBefore: (NSString )eventId
    UserId:(NSString
    )userId
    success:(APISuccessBlock)success
    failure:(APIFailureBlock)failure;

    
    ##### 参数说明
  • videoId – 当前列表的第一条直播数据的id
  • userId – 用户id为想获取直播的用户id, nil则获取广场数据,下同
  • success – 成功回调
  • failure – 失败回调
    示例
    CDAEvent *firstEvent = self.events.firstObject;//取event的第一条数据
    //tips: userid区分 获取广场数据,还是个人数据
    [[CDAAPIManager sharedManager]getEventsBefore:firstEvent.id UserId:nil success:^(id result) {
    NSLog(@"--下拉直播数据:%@",result);
    } failure:^(NSError *error) {
    }];

    上拉获取更多直播数据

    函数定义
  • (void) getEventsAfter:(NSString )eventId
    UserId:(NSString
    )userId
    success:(APISuccessBlock)success
    failure:(APIFailureBlock)failure;

    
    ##### 参数说明
  • videoId – 当前列表的最后一条直播数据的id
  • userId – 用户id
  • success – 成功回调
  • failure – 失败回调
    示例
    CDAEvent *lastEvent = self.events.lastObject;
    //tips: userid区分 获取广场数据,还是个人数据
    [[CDAAPIManager sharedManager]getEventsAfter:lastEvent.id UserId:nil success:^(id result) {
    NSLog(@"--上拉直播数据:%@",result);
    } failure:^(NSError *error) {
    }];

获取直播详情数据

函数定义
- (void) getEventById:(NSString *)eventId 
         AndChannelId:(NSString *)channelId 
              success:(APISuccessBlock)success 
              failure:(APIFailureBlock)failure;
参数说明
  • eventId – 直播eventId
  • channelId – 直播chennelId
  • success – 成功回调
  • failure – 失败回调
    示例
  • (IBAction)clickLiveingData:(id)sender {
    if (self.events.count <= 0) {
    [SVProgressHUD showErrorWithStatus:@"请先获取直播数据"];
    return;
    }
    CDAEvent event = self.events.firstObject;
    CDAChannel
    channel = event.channels.lastObject;
    [[CDAAPIManager sharedManager]getEventById:event.id AndChannelId:channel.id success:^(id result) {
    [SVProgressHUD showSuccessWithStatus:@"获取直播详情数据成功"];
    NSLog(@"–直播详情数据:%@",result);
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"获取失败"];
    }];
    }

    
    ---

获取直播在线人数及直播状态

函数定义
- (void) getUserCountByChannelId:(NSString *)channelID 
                          success:(APISuccessBlock)success 
                          failure:(APIFailureBlock)failure;
参数说明
  • channelId – 直播chennelId
  • success – 成功回调
  • failure – 失败回调
    示例
  • (IBAction)getOnLineAndLiveStatus:(id)sender {
    if (self.events.count <= 0) {
    [SVProgressHUD showErrorWithStatus:@"请先获取直播数据"];
    return;
    }
    CDAEvent event = self.events.firstObject;
    CDAChannel
    channel = event.channels.lastObject;
    [[CDAAPIManager sharedManager]getUserCountByChannelId:channel.id success:^(id result) {
    [SVProgressHUD showSuccessWithStatus:@"获取成功"];
    [self.liveStatus setText:[NSString stringWithFormat:@":在线人数%@ 直播状态:%@", [result objectForKey:@"popularity"] == nil ? @"0" : [result objectForKey:@"popularity"],[result objectForKey:@"isLive"]]];
    } failure:^(NSError *error) {
    [SVProgressHUD showErrorWithStatus:@"获取失败"];
    }];
    }

    
    ---

Latest podspec

{
    "name": "APPGear-iOS",
    "version": "1.0.1",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "APPGear-iOS",
    "description": "u76f4u64adAPI,u89c6u9891API,u767bu5f55API,u521bu5efau76f4u64adAPI,u53d1u5e03u89c6u9891API",
    "homepage": "https://github.com/camsgear/APPGear-iOS",
    "social_media_url": "https://github.com/camsgear/APPGear-iOS.git",
    "authors": {
        "Camsgear": "[email protected]"
    },
    "source": {
        "git": "https://github.com/camsgear/APPGear-iOS.git",
        "tag": "1.0.1"
    },
    "source_files": "CamsgearAPIManagerDemo/*",
    "platforms": {
        "ios": "8.0"
    },
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This