Commit 9d8ea58bed8efbf33c5d8900c7a180c4545b5a0f

Authored by 王军波
1 parent 22a446fb

增加评论功能

Showing 27 changed files with 703 additions and 27 deletions
CNLiveChatSDKDemo/CNLiveChatManager.framework/CNLiveChatManager
No preview for this file type
CNLiveChatSDKDemo/CNLiveChatManager.framework/Headers/CNLiveChatManager.h
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 75
76 @return SDK版本号 76 @return SDK版本号
77 */ 77 */
78 -+ (NSString *)getVersion; 78 ++ (NSString *)getCNLiveChatVersion;
79 79
80 80
81 /** 81 /**
@@ -219,5 +219,15 @@ @@ -219,5 +219,15 @@
219 targetId:(NSString *)targetId 219 targetId:(NSString *)targetId
220 count:(int)count; 220 count:(int)count;
221 221
  222 +/**
  223 +获取聊天室成员人数
  224 +
  225 +@param targetId 聊天室ID
  226 +@param successBlock 成功回调,返回聊天室成员数量
  227 +@param errorBlock 失败回调,返回错误代码
  228 +*/
  229 +- (void)getChatRoomInfo:(NSString *)targetId
  230 + success:(void (^)(int totalMemberCount))successBlock
  231 + error:(void (^)(CNLiveChatErrorCode status))errorBlock;
222 232
223 @end 233 @end
CNLiveChatSDKDemo/CNLiveChatManager.framework/Headers/CNLiveCommentCountResult.h 0 → 100644
  1 +//
  2 +// CNLiveCommentCountResult.h
  3 +// CNLiveChatManager
  4 +//
  5 +// Created by cnliveJunBo on 17/6/7.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveCommentCountResult : NSObject
  12 +
  13 +@property (nonatomic, copy) NSString *count;
  14 +
  15 +@property (nonatomic, copy) NSString *programId;
  16 +
  17 +@end
CNLiveChatSDKDemo/CNLiveChatManager.framework/Headers/CNLiveCommentDetailInfoResult.h 0 → 100644
  1 +//
  2 +// CNLiveCommentDetailInfoResult.h
  3 +// CNLiveChatManagerSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/6.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveCommentDetailInfoResult : NSObject
  12 +
  13 +// 评论ID
  14 +@property (nonatomic, copy) NSString *commentId;
  15 +// 节目ID
  16 +@property (nonatomic, copy) NSString *pid;
  17 +// 用户ID
  18 +@property (nonatomic, copy) NSString *uid;
  19 +// 昵称
  20 +@property (nonatomic, copy) NSString *nick;
  21 +// 评论者头像
  22 +@property (nonatomic, copy) NSString *facepath;
  23 +// 评论内容
  24 +@property (nonatomic, copy) NSString *content;
  25 +// 评论时间
  26 +@property (nonatomic, copy) NSString *created_at;
  27 +// 点赞数
  28 +@property (nonatomic, copy) NSString *praise;
  29 +
  30 +@end
CNLiveChatSDKDemo/CNLiveChatManager.framework/Headers/CNLiveCommentListResult.h 0 → 100644
  1 +//
  2 +// CNLiveCommentListResult.h
  3 +// CNLiveChatManagerSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/6.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNLiveCommentDetailInfoResult.h"
  11 +
  12 +@interface CNLiveCommentListResult : NSObject
  13 +
  14 +// 下一页
  15 +@property (nonatomic, copy) NSString *next_cursor;
  16 +// 上一页
  17 +@property (nonatomic, copy) NSString *previous_cursor;
  18 +// 总页数
  19 +@property (nonatomic, copy) NSString *total_number;
  20 +// 总条数
  21 +@property (nonatomic, copy) NSString *total_columns;
  22 +// 评论详情数组
  23 +@property (nonatomic, strong) NSArray <CNLiveCommentDetailInfoResult *> *comments;
  24 +
  25 +@end
CNLiveChatSDKDemo/CNLiveChatManager.framework/Headers/CNLiveCommentManager.h 0 → 100644
  1 +//
  2 +// CNLiveCommentManager.h
  3 +// CNLiveChatManager
  4 +//
  5 +// Created by cnliveJunBo on 17/6/6.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNLiveCommentListResult.h"
  11 +#import "CNLiveCommentCountResult.h"
  12 +
  13 +@interface CNLiveCommentManager : NSObject
  14 +
  15 +/**
  16 + 获取SDK版本号
  17 +
  18 + @return SDK版本号
  19 + */
  20 ++ (NSString *)getCNLiveCommentVersion;
  21 +
  22 +
  23 +/**
  24 + 获取视讯评论核心类单例
  25 +
  26 + @return 视讯评论核心类单例
  27 +
  28 + @discussion 您可以通过此方法,获取视讯评论的单例,访问对象中的属性和方法。
  29 + */
  30 ++ (instancetype)sharedCNLiveCommentManager;
  31 +
  32 +
  33 +/**
  34 + 注册视讯评论
  35 +
  36 + @param appId 从视讯云平台获取到的appId
  37 + @param appKey 从视讯云平台获取到的appKey
  38 + */
  39 +- (void)registerWithAppId:(NSString *)appId appKey:(NSString *)appKey;
  40 +
  41 +
  42 +/**
  43 + 获取评论列表
  44 +
  45 + @param programId 节目ID
  46 + @param page 页号
  47 + @param pageSize 每页显示的条数
  48 + @param successBlock 获取列表成功回调
  49 + @param errorBlock 获取列表失败回调
  50 + */
  51 +- (void)getCommentListWithProgramId:(NSString *)programId
  52 + page:(NSString *)page
  53 + pageSize:(NSString *)pageSize
  54 + success:(void (^)(CNLiveCommentListResult *result))successBlock
  55 + error:(void (^)(NSString *error))errorBlock;
  56 +
  57 +
  58 +/**
  59 + 评论一条节目
  60 +
  61 + @param programId 节目ID
  62 + @param sid 用户ID
  63 + @param comment 评论内容
  64 + @param completionBlock 评论结果回调,{errorCode:"0",errorMsg:"成功"},
  65 + {errorCode:"xxx",//错误代码(非0)errorMsg:"失败" //错误信息}
  66 + */
  67 +- (void)commentOnProgramWithProgramId:(NSString *)programId
  68 + sid:(NSString *)sid
  69 + comment:(NSString *)comment
  70 + completion:(void (^)(NSString *errorCode, NSString *errorMsg))completionBlock;
  71 +
  72 +
  73 +/**
  74 + 给评论点赞
  75 +
  76 + @param programId 节目ID
  77 + @param sid 用户ID
  78 + @param commentId 评论ID
  79 + @param completionBlock 点赞结果回调,{errorCode:"0",errorMsg:"成功"},
  80 + {errorCode:"xxx",//错误代码(非0)errorMsg:"失败" //错误信息}
  81 + */
  82 +- (void)commentaryLikeWithProgramId:(NSString *)programId
  83 + sid:(NSString *)sid
  84 + commentId:(NSString *)commentId
  85 + completion:(void (^)(NSString *errorCode, NSString *errorMsg))completionBlock;
  86 +
  87 +
  88 +/**
  89 + 获取节目评论数
  90 +
  91 + @param programIds 节目ID数组(数组内可以是字符串类型,可以是NSNumber类型,其他不支持)
  92 + @param completionBlock 获取节目评论数回调结果,{errorCode:"0",errorMsg:"成功"},
  93 + {errorCode:"xxx",//错误代码(非0)errorMsg:"失败" //错误信息}
  94 + commentArray:CNLiveCommentCountResult类型数组,CNLiveCommentCountResult包含节目ID及对应的评论数;
  95 + */
  96 +- (void)getCommentCountWithProgramIds:(NSArray *)programIds
  97 + completion:(void (^)(NSString *errorCode, NSString *errorMsg, NSArray <CNLiveCommentCountResult *>*commentArray))completionBlock;
  98 +
  99 +@end
CNLiveChatSDKDemo/CNLiveChatManager.framework/Info.plist
No preview for this file type
CNLiveChatSDKDemo/CNLiveChatSDKDemo.xcodeproj/project.pbxproj
@@ -7,20 +7,22 @@ @@ -7,20 +7,22 @@
7 objects = { 7 objects = {
8 8
9 /* Begin PBXBuildFile section */ 9 /* Begin PBXBuildFile section */
  10 + D2239CD41EE94F31005572FB /* praiseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2239CD31EE94F31005572FB /* praiseModel.m */; };
10 D231941F1E70101500111C3B /* MessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D231941E1E70101500111C3B /* MessageModel.m */; }; 11 D231941F1E70101500111C3B /* MessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D231941E1E70101500111C3B /* MessageModel.m */; };
11 D231C8A61E6FFC2700EAC427 /* ChatRoomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */; }; 12 D231C8A61E6FFC2700EAC427 /* ChatRoomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */; };
12 D231C8A91E6FFD3100EAC427 /* PrivateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */; }; 13 D231C8A91E6FFD3100EAC427 /* PrivateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */; };
  14 + D244EFE61EE9176200C1B9DB /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2868FED1EE916780037DECF /* CNLiveChatManager.framework */; };
  15 + D244EFE71EE9176200C1B9DB /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2868FED1EE916780037DECF /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
  16 + D244EFEA1EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D244EFE91EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m */; };
13 D264D5A51E6FDE02002CDF41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A41E6FDE02002CDF41 /* main.m */; }; 17 D264D5A51E6FDE02002CDF41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A41E6FDE02002CDF41 /* main.m */; };
14 D264D5A81E6FDE02002CDF41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A71E6FDE02002CDF41 /* AppDelegate.m */; }; 18 D264D5A81E6FDE02002CDF41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A71E6FDE02002CDF41 /* AppDelegate.m */; };
15 D264D5AB1E6FDE02002CDF41 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5AA1E6FDE02002CDF41 /* ViewController.m */; }; 19 D264D5AB1E6FDE02002CDF41 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5AA1E6FDE02002CDF41 /* ViewController.m */; };
16 D264D5AE1E6FDE02002CDF41 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D264D5AC1E6FDE02002CDF41 /* Main.storyboard */; }; 20 D264D5AE1E6FDE02002CDF41 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D264D5AC1E6FDE02002CDF41 /* Main.storyboard */; };
17 D264D5B01E6FDE02002CDF41 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D264D5AF1E6FDE02002CDF41 /* Assets.xcassets */; }; 21 D264D5B01E6FDE02002CDF41 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D264D5AF1E6FDE02002CDF41 /* Assets.xcassets */; };
18 D264D5B31E6FDE02002CDF41 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D264D5B11E6FDE02002CDF41 /* LaunchScreen.storyboard */; }; 22 D264D5B31E6FDE02002CDF41 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D264D5B11E6FDE02002CDF41 /* LaunchScreen.storyboard */; };
19 - D27122051E8FBE2A0015B525 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D27122011E8FBE1E0015B525 /* CNLiveMsgTools.framework */; };  
20 - D27122061E8FBE2A0015B525 /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D27122011E8FBE1E0015B525 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };  
21 - D27EE3ED1E9E23CF004B6CB5 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D27EE3EC1E9E23CF004B6CB5 /* CNLiveChatManager.framework */; };  
22 - D27EE3EE1E9E23D3004B6CB5 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D27EE3EC1E9E23CF004B6CB5 /* CNLiveChatManager.framework */; };  
23 - D27EE3EF1E9E23D3004B6CB5 /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D27EE3EC1E9E23CF004B6CB5 /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 23 + D2868FEC1EE914690037DECF /* CommentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2868FEB1EE914690037DECF /* CommentViewController.m */; };
  24 + D2CE6F001EE80EE7007CEA51 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */; };
  25 + D2CE6F061EE80EF6007CEA51 /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
24 /* End PBXBuildFile section */ 26 /* End PBXBuildFile section */
25 27
26 /* Begin PBXCopyFilesBuildPhase section */ 28 /* Begin PBXCopyFilesBuildPhase section */
@@ -30,8 +32,8 @@ @@ -30,8 +32,8 @@
30 dstPath = ""; 32 dstPath = "";
31 dstSubfolderSpec = 10; 33 dstSubfolderSpec = 10;
32 files = ( 34 files = (
33 - D27122061E8FBE2A0015B525 /* CNLiveMsgTools.framework in Embed Frameworks */,  
34 - D27EE3EF1E9E23D3004B6CB5 /* CNLiveChatManager.framework in Embed Frameworks */, 35 + D2CE6F061EE80EF6007CEA51 /* CNLiveMsgTools.framework in Embed Frameworks */,
  36 + D244EFE71EE9176200C1B9DB /* CNLiveChatManager.framework in Embed Frameworks */,
35 ); 37 );
36 name = "Embed Frameworks"; 38 name = "Embed Frameworks";
37 runOnlyForDeploymentPostprocessing = 0; 39 runOnlyForDeploymentPostprocessing = 0;
@@ -39,12 +41,16 @@ @@ -39,12 +41,16 @@
39 /* End PBXCopyFilesBuildPhase section */ 41 /* End PBXCopyFilesBuildPhase section */
40 42
41 /* Begin PBXFileReference section */ 43 /* Begin PBXFileReference section */
  44 + D2239CD21EE94F31005572FB /* praiseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = praiseModel.h; sourceTree = "<group>"; };
  45 + D2239CD31EE94F31005572FB /* praiseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = praiseModel.m; sourceTree = "<group>"; };
42 D231941D1E70101500111C3B /* MessageModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageModel.h; sourceTree = "<group>"; }; 46 D231941D1E70101500111C3B /* MessageModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageModel.h; sourceTree = "<group>"; };
43 D231941E1E70101500111C3B /* MessageModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageModel.m; sourceTree = "<group>"; }; 47 D231941E1E70101500111C3B /* MessageModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageModel.m; sourceTree = "<group>"; };
44 D231C8A41E6FFC2700EAC427 /* ChatRoomViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatRoomViewController.h; sourceTree = "<group>"; }; 48 D231C8A41E6FFC2700EAC427 /* ChatRoomViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatRoomViewController.h; sourceTree = "<group>"; };
45 D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatRoomViewController.m; sourceTree = "<group>"; }; 49 D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatRoomViewController.m; sourceTree = "<group>"; };
46 D231C8A71E6FFD3100EAC427 /* PrivateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateViewController.h; sourceTree = "<group>"; }; 50 D231C8A71E6FFD3100EAC427 /* PrivateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateViewController.h; sourceTree = "<group>"; };
47 D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrivateViewController.m; sourceTree = "<group>"; }; 51 D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrivateViewController.m; sourceTree = "<group>"; };
  52 + D244EFE81EE9246D00C1B9DB /* CNLiveCommentTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveCommentTableViewCell.h; sourceTree = "<group>"; };
  53 + D244EFE91EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveCommentTableViewCell.m; sourceTree = "<group>"; };
48 D264D5A01E6FDE02002CDF41 /* CNLiveChatSDKDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNLiveChatSDKDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 54 D264D5A01E6FDE02002CDF41 /* CNLiveChatSDKDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNLiveChatSDKDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
49 D264D5A41E6FDE02002CDF41 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 55 D264D5A41E6FDE02002CDF41 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
50 D264D5A61E6FDE02002CDF41 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; 56 D264D5A61E6FDE02002CDF41 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -56,8 +62,10 @@ @@ -56,8 +62,10 @@
56 D264D5B21E6FDE02002CDF41 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 62 D264D5B21E6FDE02002CDF41 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
57 D264D5B41E6FDE02002CDF41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 63 D264D5B41E6FDE02002CDF41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
58 D264D5BE1E6FDEED002CDF41 /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = "<group>"; }; 64 D264D5BE1E6FDEED002CDF41 /* PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrefixHeader.pch; sourceTree = "<group>"; };
59 - D27122011E8FBE1E0015B525 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };  
60 - D27EE3EC1E9E23CF004B6CB5 /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; }; 65 + D2868FEA1EE914690037DECF /* CommentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentViewController.h; sourceTree = "<group>"; };
  66 + D2868FEB1EE914690037DECF /* CommentViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentViewController.m; sourceTree = "<group>"; };
  67 + D2868FED1EE916780037DECF /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; };
  68 + D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };
61 /* End PBXFileReference section */ 69 /* End PBXFileReference section */
62 70
63 /* Begin PBXFrameworksBuildPhase section */ 71 /* Begin PBXFrameworksBuildPhase section */
@@ -65,9 +73,8 @@ @@ -65,9 +73,8 @@
65 isa = PBXFrameworksBuildPhase; 73 isa = PBXFrameworksBuildPhase;
66 buildActionMask = 2147483647; 74 buildActionMask = 2147483647;
67 files = ( 75 files = (
68 - D27122051E8FBE2A0015B525 /* CNLiveMsgTools.framework in Frameworks */,  
69 - D27EE3ED1E9E23CF004B6CB5 /* CNLiveChatManager.framework in Frameworks */,  
70 - D27EE3EE1E9E23D3004B6CB5 /* CNLiveChatManager.framework in Frameworks */, 76 + D2CE6F001EE80EE7007CEA51 /* CNLiveMsgTools.framework in Frameworks */,
  77 + D244EFE61EE9176200C1B9DB /* CNLiveChatManager.framework in Frameworks */,
71 ); 78 );
72 runOnlyForDeploymentPostprocessing = 0; 79 runOnlyForDeploymentPostprocessing = 0;
73 }; 80 };
@@ -83,6 +90,8 @@ @@ -83,6 +90,8 @@
83 D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */, 90 D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */,
84 D231C8A41E6FFC2700EAC427 /* ChatRoomViewController.h */, 91 D231C8A41E6FFC2700EAC427 /* ChatRoomViewController.h */,
85 D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */, 92 D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */,
  93 + D2868FEA1EE914690037DECF /* CommentViewController.h */,
  94 + D2868FEB1EE914690037DECF /* CommentViewController.m */,
86 ); 95 );
87 name = Controller; 96 name = Controller;
88 sourceTree = "<group>"; 97 sourceTree = "<group>";
@@ -92,15 +101,26 @@ @@ -92,15 +101,26 @@
92 children = ( 101 children = (
93 D231941D1E70101500111C3B /* MessageModel.h */, 102 D231941D1E70101500111C3B /* MessageModel.h */,
94 D231941E1E70101500111C3B /* MessageModel.m */, 103 D231941E1E70101500111C3B /* MessageModel.m */,
  104 + D2239CD21EE94F31005572FB /* praiseModel.h */,
  105 + D2239CD31EE94F31005572FB /* praiseModel.m */,
95 ); 106 );
96 name = Model; 107 name = Model;
97 sourceTree = "<group>"; 108 sourceTree = "<group>";
98 }; 109 };
  110 + D244EFEB1EE9247C00C1B9DB /* View */ = {
  111 + isa = PBXGroup;
  112 + children = (
  113 + D244EFE81EE9246D00C1B9DB /* CNLiveCommentTableViewCell.h */,
  114 + D244EFE91EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m */,
  115 + );
  116 + name = View;
  117 + sourceTree = "<group>";
  118 + };
99 D264D5971E6FDE02002CDF41 = { 119 D264D5971E6FDE02002CDF41 = {
100 isa = PBXGroup; 120 isa = PBXGroup;
101 children = ( 121 children = (
102 - D27EE3EC1E9E23CF004B6CB5 /* CNLiveChatManager.framework */,  
103 - D27122011E8FBE1E0015B525 /* CNLiveMsgTools.framework */, 122 + D2868FED1EE916780037DECF /* CNLiveChatManager.framework */,
  123 + D2CE6EFF1EE80EE7007CEA51 /* CNLiveMsgTools.framework */,
104 D264D5A21E6FDE02002CDF41 /* CNLiveChatSDKDemo */, 124 D264D5A21E6FDE02002CDF41 /* CNLiveChatSDKDemo */,
105 D264D5A11E6FDE02002CDF41 /* Products */, 125 D264D5A11E6FDE02002CDF41 /* Products */,
106 ); 126 );
@@ -120,6 +140,7 @@ @@ -120,6 +140,7 @@
120 D264D5A61E6FDE02002CDF41 /* AppDelegate.h */, 140 D264D5A61E6FDE02002CDF41 /* AppDelegate.h */,
121 D264D5A71E6FDE02002CDF41 /* AppDelegate.m */, 141 D264D5A71E6FDE02002CDF41 /* AppDelegate.m */,
122 D23194201E70101B00111C3B /* Model */, 142 D23194201E70101B00111C3B /* Model */,
  143 + D244EFEB1EE9247C00C1B9DB /* View */,
123 D231941C1E700FEC00111C3B /* Controller */, 144 D231941C1E700FEC00111C3B /* Controller */,
124 D264D5BE1E6FDEED002CDF41 /* PrefixHeader.pch */, 145 D264D5BE1E6FDEED002CDF41 /* PrefixHeader.pch */,
125 D264D5AC1E6FDE02002CDF41 /* Main.storyboard */, 146 D264D5AC1E6FDE02002CDF41 /* Main.storyboard */,
@@ -214,10 +235,13 @@ @@ -214,10 +235,13 @@
214 files = ( 235 files = (
215 D264D5AB1E6FDE02002CDF41 /* ViewController.m in Sources */, 236 D264D5AB1E6FDE02002CDF41 /* ViewController.m in Sources */,
216 D264D5A81E6FDE02002CDF41 /* AppDelegate.m in Sources */, 237 D264D5A81E6FDE02002CDF41 /* AppDelegate.m in Sources */,
  238 + D2868FEC1EE914690037DECF /* CommentViewController.m in Sources */,
217 D231C8A91E6FFD3100EAC427 /* PrivateViewController.m in Sources */, 239 D231C8A91E6FFD3100EAC427 /* PrivateViewController.m in Sources */,
218 D264D5A51E6FDE02002CDF41 /* main.m in Sources */, 240 D264D5A51E6FDE02002CDF41 /* main.m in Sources */,
219 D231C8A61E6FFC2700EAC427 /* ChatRoomViewController.m in Sources */, 241 D231C8A61E6FFC2700EAC427 /* ChatRoomViewController.m in Sources */,
  242 + D244EFEA1EE9246D00C1B9DB /* CNLiveCommentTableViewCell.m in Sources */,
220 D231941F1E70101500111C3B /* MessageModel.m in Sources */, 243 D231941F1E70101500111C3B /* MessageModel.m in Sources */,
  244 + D2239CD41EE94F31005572FB /* praiseModel.m in Sources */,
221 ); 245 );
222 runOnlyForDeploymentPostprocessing = 0; 246 runOnlyForDeploymentPostprocessing = 0;
223 }; 247 };
CNLiveChatSDKDemo/CNLiveChatSDKDemo/AppDelegate.m
@@ -21,8 +21,9 @@ @@ -21,8 +21,9 @@
21 // 必须初始化 但不要重复初始化 21 // 必须初始化 但不要重复初始化
22 [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:@"a425987ebc86e352b3373c25d5bd082d0cc248b4043028" appId:@"60_irn9cdak77"]; 22 [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:@"a425987ebc86e352b3373c25d5bd082d0cc248b4043028" appId:@"60_irn9cdak77"];
23 23
24 - // 连接服务器,相当于匿名游客身份登录  
25 - // ***** 建议连接服务器操作写在 AppDelegate 里面 24 +
  25 + // connectServer 连接服务器,相当于匿名游客身份登录
  26 + // 建议连接服务器操作写在 AppDelegate 里面
26 27
27 // [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{ 28 // [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
28 // NSLog(@"成功"); 29 // NSLog(@"成功");
@@ -30,10 +31,14 @@ @@ -30,10 +31,14 @@
30 // NSLog(@"失败"); 31 // NSLog(@"失败");
31 // }]; 32 // }];
32 33
33 - // 以用户信息登陆 可以在登陆处实现此方法  
34 - // ***** 一次登陆即可,之后无论是网络出现异常或者App有前后台的切换等,SDK都会负责自动重连。  
35 - // ***** 除非您已经手动将连接断开,或者少数无法自动重连的情况,否则您不需要自己再手动重连。  
36 - CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170311" name:@"11" portrait:@""]; 34 +
  35 +
  36 + // loginServer 以用户信息登陆,不要和 connectServer 连接服务器方法一起调用,作用相同,只是一个有用户信息,一个没有相当于游客;
  37 + // 一次登陆即可,之后无论是网络出现异常或者App有前后台的切换等,SDK都会负责自动重连。
  38 + // 除非您已经手动将连接断开,或者杀死程序,或者少数无法自动重连的情况,否则您不需要自己再手动重连。
  39 + // 客户端使用时可以判断一下当前用户的登录状态,未登录就用上面的 connectServer 的方法连接服务器,已登录就用 loginServer 此方法连接服务器;
  40 +
  41 + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170319" name:@"11" portrait:@""];
37 42
38 [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) { 43 [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) {
39 44
CNLiveChatSDKDemo/CNLiveChatSDKDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -2,6 +2,16 @@ @@ -2,6 +2,16 @@
2 "images" : [ 2 "images" : [
3 { 3 {
4 "idiom" : "iphone", 4 "idiom" : "iphone",
  5 + "size" : "20x20",
  6 + "scale" : "2x"
  7 + },
  8 + {
  9 + "idiom" : "iphone",
  10 + "size" : "20x20",
  11 + "scale" : "3x"
  12 + },
  13 + {
  14 + "idiom" : "iphone",
5 "size" : "29x29", 15 "size" : "29x29",
6 "scale" : "2x" 16 "scale" : "2x"
7 }, 17 },
@@ -32,6 +42,16 @@ @@ -32,6 +42,16 @@
32 }, 42 },
33 { 43 {
34 "idiom" : "ipad", 44 "idiom" : "ipad",
  45 + "size" : "20x20",
  46 + "scale" : "1x"
  47 + },
  48 + {
  49 + "idiom" : "ipad",
  50 + "size" : "20x20",
  51 + "scale" : "2x"
  52 + },
  53 + {
  54 + "idiom" : "ipad",
35 "size" : "29x29", 55 "size" : "29x29",
36 "scale" : "1x" 56 "scale" : "1x"
37 }, 57 },
@@ -59,6 +79,11 @@ @@ -59,6 +79,11 @@
59 "idiom" : "ipad", 79 "idiom" : "ipad",
60 "size" : "76x76", 80 "size" : "76x76",
61 "scale" : "2x" 81 "scale" : "2x"
  82 + },
  83 + {
  84 + "idiom" : "ipad",
  85 + "size" : "83.5x83.5",
  86 + "scale" : "2x"
62 } 87 }
63 ], 88 ],
64 "info" : { 89 "info" : {
CNLiveChatSDKDemo/CNLiveChatSDKDemo/Assets.xcassets/Contents.json 0 → 100644
  1 +{
  2 + "info" : {
  3 + "version" : 1,
  4 + "author" : "xcode"
  5 + }
  6 +}
0 \ No newline at end of file 7 \ No newline at end of file
CNLiveChatSDKDemo/CNLiveChatSDKDemo/Assets.xcassets/videoSupport.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "videoSupport.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 \ No newline at end of file 22 \ No newline at end of file
CNLiveChatSDKDemo/CNLiveChatSDKDemo/Assets.xcassets/videoSupport.imageset/videoSupport.png 0 → 100644

1.94 KB

CNLiveChatSDKDemo/CNLiveChatSDKDemo/Assets.xcassets/videoSupportNormal.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "videoSupportNormal.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 \ No newline at end of file 22 \ No newline at end of file
CNLiveChatSDKDemo/CNLiveChatSDKDemo/Assets.xcassets/videoSupportNormal.imageset/videoSupportNormal.png 0 → 100644

2.01 KB

CNLiveChatSDKDemo/CNLiveChatSDKDemo/CNLiveCommentTableViewCell.h 0 → 100644
  1 +//
  2 +// CNLiveCommentTableViewCell.h
  3 +// CNLiveChatSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/8.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface CNLiveCommentTableViewCell : UITableViewCell
  12 +
  13 +@property (nonatomic, strong) UILabel *commentLabel;
  14 +
  15 +@property (nonatomic, strong) UIButton *praiseButton;
  16 +
  17 +@property (nonatomic, strong) CNLiveCommentDetailInfoResult *model;
  18 +
  19 +@property (nonatomic, strong) praiseModel *praiseModel;
  20 +
  21 +@end
CNLiveChatSDKDemo/CNLiveChatSDKDemo/CNLiveCommentTableViewCell.m 0 → 100644
  1 +//
  2 +// CNLiveCommentTableViewCell.m
  3 +// CNLiveChatSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/8.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveCommentTableViewCell.h"
  10 +
  11 +@implementation CNLiveCommentTableViewCell
  12 +
  13 +- (void)setModel:(CNLiveCommentDetailInfoResult *)model {
  14 +
  15 + if (_model != model) {
  16 + _model = model;
  17 + }
  18 + NSString *nickName = model.nick ? model.nick : @"游客";
  19 + NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@: %@",nickName,model.content]];
  20 +
  21 + [AttributedStr addAttribute:NSForegroundColorAttributeName
  22 + value:[UIColor redColor]
  23 + range:NSMakeRange(0, nickName.length)];
  24 +
  25 + _commentLabel.attributedText = AttributedStr;
  26 +
  27 + [_praiseButton setTitle:model.praise forState:UIControlStateNormal];
  28 + [_praiseButton setImageEdgeInsets:UIEdgeInsetsMake(12, 5, 12, 35)];
  29 + [_praiseButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -60, 0, 0)];
  30 +}
  31 +
  32 +- (void)setPraiseModel:(praiseModel *)praiseModel {
  33 +
  34 + if (_praiseModel != praiseModel) {
  35 + _praiseModel = praiseModel;
  36 + }
  37 + BOOL isSelected = praiseModel.isPraised;
  38 + _praiseButton.selected = isSelected;
  39 + [_praiseButton setUserInteractionEnabled:!isSelected];
  40 +}
  41 +
  42 +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  43 +{
  44 + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  45 + if (self) {
  46 + [self.contentView addSubview:self.commentLabel];
  47 + [self.contentView addSubview:self.praiseButton];
  48 + }
  49 + return self;
  50 +}
  51 +
  52 +#pragma mark - Get Method !!!!!!!!!!!!!!!!!!!!!!
  53 +- (UILabel *)commentLabel {
  54 +
  55 + if (!_commentLabel) {
  56 + _commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.contentView.bounds.size.width - 80, self.contentView.bounds.size.height)];
  57 + }
  58 + return _commentLabel;
  59 +}
  60 +
  61 +- (UIButton *)praiseButton {
  62 +
  63 + if (!_praiseButton) {
  64 + _praiseButton = [UIButton buttonWithType:UIButtonTypeCustom];
  65 + _praiseButton.frame = CGRectMake(self.contentView.bounds.size.width - 60, 0, 60, 44);
  66 + [_praiseButton setImage:[UIImage imageNamed:@"videoSupportNormal"] forState:UIControlStateNormal];
  67 + [_praiseButton setImage:[UIImage imageNamed:@"videoSupport"] forState:UIControlStateSelected];
  68 + _praiseButton.titleLabel.font = [UIFont systemFontOfSize:12];
  69 + [_praiseButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  70 + _praiseButton.backgroundColor = [UIColor whiteColor];
  71 + [_praiseButton addTarget:self action:@selector(praiseAction:) forControlEvents:UIControlEventTouchUpInside];
  72 + }
  73 + return _praiseButton;
  74 +}
  75 +
  76 +- (void)praiseAction:(UIButton *)btn { // 点赞
  77 +
  78 + [[CNLiveCommentManager sharedCNLiveCommentManager] commentaryLikeWithProgramId:@"123" sid:@"888" commentId:_model.commentId completion:^(NSString *errorCode, NSString *errorMsg) {
  79 +
  80 + if ([errorCode isEqualToString:@"0"]) {
  81 +
  82 + NSLog(@"success");
  83 + btn.selected = YES;
  84 + [btn setUserInteractionEnabled:NO];
  85 + _praiseModel.isPraised = YES;
  86 + _model.praise = [NSString stringWithFormat:@"%ld",[_model.praise integerValue] + 1];
  87 + [_praiseButton setTitle:_model.praise forState:UIControlStateNormal];
  88 +
  89 + } else {
  90 + NSLog(@"failed");
  91 + }
  92 + }];
  93 +}
  94 +
  95 +- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  96 + [super setSelected:selected animated:animated];
  97 +
  98 + // Configure the view for the selected state
  99 +}
  100 +
  101 +@end
CNLiveChatSDKDemo/CNLiveChatSDKDemo/ChatRoomViewController.m
@@ -46,7 +46,7 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -46,7 +46,7 @@ static NSString *cellId = @&quot;cellId&quot;;
46 46
47 [self.view addSubview:self.tableView]; 47 [self.view addSubview:self.tableView];
48 UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)]; 48 UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
49 - gestureRecognizer.cancelsTouchesInView = NO; 49 + gestureRecognizer.cancelsTouchesInView = YES;
50 [self.tableView addGestureRecognizer:gestureRecognizer]; 50 [self.tableView addGestureRecognizer:gestureRecognizer];
51 [self.view addSubview:self.textField]; 51 [self.view addSubview:self.textField];
52 52
@@ -57,7 +57,7 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -57,7 +57,7 @@ static NSString *cellId = @&quot;cellId&quot;;
57 57
58 [super viewWillDisappear:animated]; 58 [super viewWillDisappear:animated];
59 59
60 - [[CNLiveChatManager sharedCNLiveChatManager] quitChatRoom:@"7788" success:^(NSString *targetId) { 60 + [[CNLiveChatManager sharedCNLiveChatManager] quitChatRoom:@"67_7788" success:^(NSString *targetId) {
61 NSLog(@"退出聊天室:%@成功",targetId); 61 NSLog(@"退出聊天室:%@成功",targetId);
62 } error:^(CNLiveChatErrorCode errors, NSString *targetId) { 62 } error:^(CNLiveChatErrorCode errors, NSString *targetId) {
63 NSLog(@"退出聊天室:%@失败,错误码:%ld",targetId,(long)errors); 63 NSLog(@"退出聊天室:%@失败,错误码:%ld",targetId,(long)errors);
@@ -173,7 +173,7 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -173,7 +173,7 @@ static NSString *cellId = @&quot;cellId&quot;;
173 NSLog(@"收到消息类型:%lu,消息ID:%@,消息内容:%@,消息发送者信息:%@,消息ID:%@",(unsigned long)message.conversationType,message.targetId,message.messageContent,message.userInfo,message.messageId); 173 NSLog(@"收到消息类型:%lu,消息ID:%@,消息内容:%@,消息发送者信息:%@,消息ID:%@",(unsigned long)message.conversationType,message.targetId,message.messageContent,message.userInfo,message.messageId);
174 174
175 // 只显示本聊天室信息 175 // 只显示本聊天室信息
176 - if (message.conversationType == CNLive_ConversationType_CHATROOM && [message.targetId isEqualToString:@"7788"]) { 176 + if (message.conversationType == CNLive_ConversationType_CHATROOM && [message.targetId isEqualToString:@"67_7788"]) {
177 177
178 MessageModel *model = [[MessageModel alloc] init]; 178 MessageModel *model = [[MessageModel alloc] init];
179 179
@@ -198,7 +198,7 @@ static NSString *cellId = @&quot;cellId&quot;; @@ -198,7 +198,7 @@ static NSString *cellId = @&quot;cellId&quot;;
198 198
199 - (void)onChatRoomJoined:(NSString *)chatroomId { 199 - (void)onChatRoomJoined:(NSString *)chatroomId {
200 200
201 - NSLog(@"成功加入聊天室:%@",chatroomId); 201 + NSLog(@"状态:成功加入聊天室:%@",chatroomId);
202 NSString *userId = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.name; 202 NSString *userId = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.name;
203 NSLog(@"当前账号ID:%@",userId); 203 NSLog(@"当前账号ID:%@",userId);
204 } 204 }
CNLiveChatSDKDemo/CNLiveChatSDKDemo/CommentViewController.h 0 → 100644
  1 +//
  2 +// CommentViewController.h
  3 +// CNLiveChatManagerSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/6.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface CommentViewController : UIViewController
  12 +
  13 +@end
CNLiveChatSDKDemo/CNLiveChatSDKDemo/CommentViewController.m 0 → 100644
  1 +//
  2 +// CommentViewController.m
  3 +// CNLiveChatManagerSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/6.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CommentViewController.h"
  10 +#import "CNLiveCommentTableViewCell.h"
  11 +
  12 +static NSString *commentCellId = @"commentCellId";
  13 +
  14 +@interface CommentViewController ()<UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>{
  15 +
  16 + NSArray *_commentArray;
  17 + NSMutableArray *_praiseArrayM;
  18 +}
  19 +
  20 +@property (nonatomic, strong) UITextField *textField;
  21 +
  22 +@property (nonatomic, strong) UILabel *commentCountLabel;
  23 +
  24 +@property (nonatomic, strong) UITableView *tableView;
  25 +
  26 +@end
  27 +
  28 +@implementation CommentViewController
  29 +
  30 +- (void)viewDidLoad {
  31 + [super viewDidLoad];
  32 +
  33 + self.title = @"评论";
  34 + // 注册评论 (*必须*)
  35 + [[CNLiveCommentManager sharedCNLiveCommentManager] registerWithAppId:@"60_irn9cdak77" appKey:@"a425987ebc86e352b3373c25d5bd082d0cc248b4043028"];
  36 +
  37 + self.view.backgroundColor = [UIColor whiteColor];
  38 + self.automaticallyAdjustsScrollViewInsets = NO;
  39 + _commentArray = [[NSArray alloc] init];
  40 + _praiseArrayM = [[NSMutableArray alloc] init];
  41 +
  42 + [self.view addSubview:self.tableView];
  43 + UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
  44 + gestureRecognizer.cancelsTouchesInView = NO;
  45 + [self.tableView addGestureRecognizer:gestureRecognizer];
  46 + [self.view addSubview:self.textField];
  47 + [self.view addSubview:self.commentCountLabel];
  48 +
  49 + [self getCommentCount]; // 评论数
  50 + [self getCommentList]; // 评论列表
  51 +}
  52 +
  53 +#pragma mark - 获取评论列表
  54 +- (void)getCommentList {
  55 +
  56 + // 评论列表
  57 + [[CNLiveCommentManager sharedCNLiveCommentManager] getCommentListWithProgramId:@"123" page:@"1" pageSize:@"10" success:^(CNLiveCommentListResult *result) {
  58 +
  59 + NSLog(@"success");
  60 + _commentArray = result.comments;
  61 + [_tableView reloadData];
  62 +
  63 + for (int i=0; i<_commentArray.count; i++) {
  64 + praiseModel *model = [[praiseModel alloc] init];
  65 + [_praiseArrayM addObject:model];
  66 + }
  67 +
  68 + } error:^(NSString *error) {
  69 +
  70 + NSLog(@"failed: %@",error);
  71 + }];
  72 +}
  73 +
  74 +#pragma mark - 获取评论数
  75 +- (void)getCommentCount {
  76 +
  77 + // 获取评论数
  78 + NSArray *array = @[@"123"];
  79 +
  80 + [[CNLiveCommentManager sharedCNLiveCommentManager] getCommentCountWithProgramIds:array completion:^(NSString *errorCode, NSString *errorMsg, NSArray<CNLiveCommentCountResult *> *commentArray) {
  81 +
  82 + if ([errorCode isEqualToString:@"0"]) {
  83 +
  84 + NSLog(@"success");
  85 + _commentCountLabel.text = [NSString stringWithFormat:@"评论数:%@",commentArray[0].count];
  86 + } else {
  87 + NSLog(@"failed");
  88 + }
  89 + }];
  90 +}
  91 +
  92 +#pragma mark - UITableViewDelegate,UITableViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!!!
  93 +
  94 +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  95 + return 1;
  96 +}
  97 +
  98 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  99 + return _commentArray.count;
  100 +}
  101 +
  102 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  103 +
  104 + CNLiveCommentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:commentCellId forIndexPath:indexPath];
  105 + [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  106 +
  107 + CNLiveCommentDetailInfoResult *model = _commentArray[indexPath.row];
  108 + praiseModel *praiseModel = _praiseArrayM[indexPath.row];
  109 +
  110 + cell.model = model;
  111 + cell.praiseModel = praiseModel;
  112 +
  113 + return cell;
  114 +}
  115 +
  116 +
  117 +#pragma mark - UITextFieldDelegate !!!!!!!!!!!!!!!!!!!!!!!!!!
  118 +- (BOOL)textFieldShouldReturn:(UITextField *)textField { // 评论
  119 +
  120 + [[CNLiveCommentManager sharedCNLiveCommentManager] commentOnProgramWithProgramId:@"123" sid:@"888" comment:textField.text completion:^(NSString *errorCode, NSString *errorMsg) {
  121 +
  122 + if ([errorCode isEqualToString:@"0"]) {
  123 + NSLog(@"success");
  124 +
  125 + [self getCommentList];
  126 + [self getCommentCount];
  127 +
  128 + } else {
  129 + NSLog(@"failed");
  130 + }
  131 +
  132 + }];
  133 + textField.text = @"";
  134 +
  135 + return YES;
  136 +}
  137 +
  138 +#pragma mark - Get Method !!!!!!!!!!!!!!!!!!!!!!!!!!
  139 +
  140 +- (UITextField *)textField {
  141 +
  142 + if (!_textField) {
  143 + _textField = [self createTextFieldWithFrame:CGRectMake(10, 74, KScreenWidth - 20, 40) font:20];
  144 + _textField.delegate = self;
  145 + }
  146 + return _textField;
  147 +}
  148 +
  149 +- (UILabel *)commentCountLabel {
  150 +
  151 + if (!_commentCountLabel) {
  152 + _commentCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 124, KScreenWidth - 20, 35)];
  153 + }
  154 + return _commentCountLabel;
  155 +}
  156 +
  157 +-(UITableView *)tableView {
  158 + if (!_tableView) {
  159 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 159, KScreenWidth, KScreenHeight - 425) style:UITableViewStylePlain];
  160 + _tableView.rowHeight = 44;
  161 + _tableView.delegate = self;
  162 + _tableView.dataSource = self;
  163 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  164 + [_tableView registerClass:[CNLiveCommentTableViewCell class] forCellReuseIdentifier:commentCellId];
  165 + }
  166 + return _tableView;
  167 +}
  168 +
  169 +#pragma mark - 隐藏键盘 !!!!!!!!!!!!!!!!!!!!!!!
  170 +- (void)hideKeyboard {
  171 +
  172 + [self.textField resignFirstResponder];
  173 +}
  174 +
  175 +#pragma mark - 创建button
  176 +- (UIButton *)createButtonWithFrame:(CGRect)frame title:(NSString *)title {
  177 +
  178 + UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  179 + [btn setFrame:frame];
  180 + btn.layer.borderWidth = 1.0f;
  181 + btn.layer.cornerRadius = frame.size.height * 0.2;
  182 + [btn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
  183 + [btn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
  184 + [btn setTitle:title forState:UIControlStateNormal];
  185 + return btn;
  186 +}
  187 +
  188 +#pragma mark - 创建文本框 !!!!!!!!!!!!!!!!!!!!!!!!!!
  189 +- (UITextField *)createTextFieldWithFrame:(CGRect)frame font:(float)font {
  190 +
  191 + UITextField *textField = [[UITextField alloc] init];
  192 + [textField setFrame:frame];
  193 + textField.returnKeyType = UIReturnKeySend;
  194 + textField.layer.borderWidth = 1.0f;
  195 + textField.layer.cornerRadius = frame.size.height * 0.1;
  196 + [textField setFont:[UIFont systemFontOfSize:font]];
  197 + textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 6, 0)];
  198 + textField.leftViewMode = UITextFieldViewModeAlways;
  199 + return textField;
  200 +}
  201 +
  202 +- (void)didReceiveMemoryWarning {
  203 + [super didReceiveMemoryWarning];
  204 + // Dispose of any resources that can be recreated.
  205 +}
  206 +
  207 +
  208 +@end
CNLiveChatSDKDemo/CNLiveChatSDKDemo/PrefixHeader.pch
@@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
16 16
17 #import <CNLiveChatManager/CNLiveChatManager.h> 17 #import <CNLiveChatManager/CNLiveChatManager.h>
18 #import "MessageModel.h" 18 #import "MessageModel.h"
  19 +#import <CNLiveChatManager/CNLiveCommentManager.h>
  20 +#import "praiseModel.h"
19 21
20 #endif 22 #endif
21 23
CNLiveChatSDKDemo/CNLiveChatSDKDemo/ViewController.m
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 #import "ViewController.h" 9 #import "ViewController.h"
10 #import "PrivateViewController.h" 10 #import "PrivateViewController.h"
11 #import "ChatRoomViewController.h" 11 #import "ChatRoomViewController.h"
  12 +#import "CommentViewController.h"
12 13
13 @interface ViewController () 14 @interface ViewController ()
14 15
@@ -16,6 +17,8 @@ @@ -16,6 +17,8 @@
16 17
17 @property (nonatomic, strong) UIButton *chatRoomBtn; 18 @property (nonatomic, strong) UIButton *chatRoomBtn;
18 19
  20 +@property (nonatomic, strong) UIButton *commentBtn;
  21 +
19 @end 22 @end
20 23
21 @implementation ViewController 24 @implementation ViewController
@@ -28,6 +31,7 @@ @@ -28,6 +31,7 @@
28 31
29 [self.view addSubview:self.privateBtn]; 32 [self.view addSubview:self.privateBtn];
30 [self.view addSubview:self.chatRoomBtn]; 33 [self.view addSubview:self.chatRoomBtn];
  34 + [self.view addSubview:self.commentBtn];
31 } 35 }
32 36
33 - (UIButton *)privateBtn { 37 - (UIButton *)privateBtn {
@@ -46,6 +50,14 @@ @@ -46,6 +50,14 @@
46 return _chatRoomBtn; 50 return _chatRoomBtn;
47 } 51 }
48 52
  53 +- (UIButton *)commentBtn {
  54 + if (!_commentBtn) {
  55 + _commentBtn = [self createButtonWithFrame:CGRectMake((KScreenWidth - 100) * 0.5, KScreenHeight * 0.8, 100, 30) title:@"评论"];
  56 + [_commentBtn addTarget:self action:@selector(goToComment) forControlEvents:UIControlEventTouchUpInside];
  57 + }
  58 + return _commentBtn;
  59 +}
  60 +
49 #pragma mark - Action 61 #pragma mark - Action
50 - (void)goToPrivate { 62 - (void)goToPrivate {
51 63
@@ -59,6 +71,12 @@ @@ -59,6 +71,12 @@
59 [self.navigationController pushViewController:chatRoom animated:YES]; 71 [self.navigationController pushViewController:chatRoom animated:YES];
60 } 72 }
61 73
  74 +- (void)goToComment {
  75 +
  76 + CommentViewController *comment = [[CommentViewController alloc] init];
  77 + [self.navigationController pushViewController:comment animated:YES];
  78 +}
  79 +
62 #pragma mark - 创建button 80 #pragma mark - 创建button
63 - (UIButton *)createButtonWithFrame:(CGRect)frame title:(NSString *)title { 81 - (UIButton *)createButtonWithFrame:(CGRect)frame title:(NSString *)title {
64 82
CNLiveChatSDKDemo/CNLiveChatSDKDemo/praiseModel.h 0 → 100644
  1 +//
  2 +// praiseModel.h
  3 +// CNLiveChatSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/8.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface praiseModel : NSObject
  12 +
  13 +@property (nonatomic, assign) BOOL isPraised;
  14 +
  15 +@end
CNLiveChatSDKDemo/CNLiveChatSDKDemo/praiseModel.m 0 → 100644
  1 +//
  2 +// praiseModel.m
  3 +// CNLiveChatSDKDemo
  4 +//
  5 +// Created by cnliveJunBo on 17/6/8.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "praiseModel.h"
  10 +
  11 +@implementation praiseModel
  12 +
  13 +@end
CNLiveChatSDKDemo/CNLiveMsgTools.framework/CNLiveMsgTools
No preview for this file type
CNLiveChatSDKDemo/CNLiveMsgTools.framework/Headers/CNLiveMsgManager.h
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 @interface CNLiveMsgManager : NSObject 11 @interface CNLiveMsgManager : NSObject
12 12
13 13
14 -+ (NSString *)getVersion; 14 ++ (NSString *)getCNLiveMsgVersion;
15 15
16 16
17 + (instancetype)sharedCNLiveMsgManager; 17 + (instancetype)sharedCNLiveMsgManager;
@@ -83,6 +83,8 @@ @@ -83,6 +83,8 @@
83 83
84 - (NSArray *)getLatestCarriers:(NSInteger)type targetId:(NSString *)targetId count:(int)count; 84 - (NSArray *)getLatestCarriers:(NSInteger)type targetId:(NSString *)targetId count:(int)count;
85 85
86 - 86 +- (void)getMeetingPointContent:(NSString *)pointId
  87 + success:(void (^)(int totalMemberCount))successBlock
  88 + error:(void (^)(NSInteger errors))errorBlock;
87 89
88 @end 90 @end
CNLiveChatSDKDemo/CNLiveMsgTools.framework/Info.plist
No preview for this file type