Commit 2cb3b5ea454ad87fc3cdfdb377051ae3f34344cf

Authored by 王军波
1 parent ba85c979

可单独更改用户昵称

CNLiveChatSDKDemo/CNLiveChatManager.framework/CNLiveChatManager
No preview for this file type
CNLiveChatSDKDemo/CNLiveChatManager.framework/Headers/CNLiveChatUserInfo.h
... ... @@ -13,7 +13,7 @@
13 13 /*!
14 14 用户ID(一旦以一个用户ID连接到服务器,就不能再修改用户ID了,如果修改也会被忽略)
15 15 */
16   -@property(nonatomic, strong) NSString *userId;
  16 +@property(nonatomic, strong, readonly) NSString *userId;
17 17  
18 18 /*!
19 19 用户名称
... ... @@ -26,7 +26,7 @@
26 26 @property(nonatomic, strong) NSString *portraitUri;
27 27  
28 28 /*!
29   - 用户信息的初始化方法
  29 + 用户信息的初始化方法,
30 30  
31 31 @param userId 用户ID
32 32 @param username 用户名称
... ...
CNLiveChatSDKDemo/CNLiveChatSDKDemo.xcodeproj/project.pbxproj
... ... @@ -7,15 +7,15 @@
7 7 objects = {
8 8  
9 9 /* Begin PBXBuildFile section */
  10 + D22551F41E79436D0056B231 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D22551F31E79436D0056B231 /* CNLiveMsgTools.framework */; };
  11 + D22551F61E7943740056B231 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D22551F51E7943740056B231 /* CNLiveChatManager.framework */; };
  12 + D22551F71E79437C0056B231 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D22551F31E79436D0056B231 /* CNLiveMsgTools.framework */; };
  13 + D22551F81E79437C0056B231 /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D22551F31E79436D0056B231 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
  14 + D22551F91E79437F0056B231 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D22551F51E7943740056B231 /* CNLiveChatManager.framework */; };
  15 + D22551FA1E79437F0056B231 /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D22551F51E7943740056B231 /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
10 16 D231941F1E70101500111C3B /* MessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D231941E1E70101500111C3B /* MessageModel.m */; };
11 17 D231C8A61E6FFC2700EAC427 /* ChatRoomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */; };
12 18 D231C8A91E6FFD3100EAC427 /* PrivateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */; };
13   - D243A7781E778B27003C573B /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D243A7771E778B27003C573B /* CNLiveMsgTools.framework */; };
14   - D243A77A1E778B2E003C573B /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D243A7791E778B2E003C573B /* CNLiveChatManager.framework */; };
15   - D243A77B1E778B54003C573B /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D243A7791E778B2E003C573B /* CNLiveChatManager.framework */; };
16   - D243A77C1E778B54003C573B /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D243A7791E778B2E003C573B /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
17   - D243A77D1E778B57003C573B /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D243A7771E778B27003C573B /* CNLiveMsgTools.framework */; };
18   - D243A77E1E778B57003C573B /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D243A7771E778B27003C573B /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
19 19 D264D5A51E6FDE02002CDF41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A41E6FDE02002CDF41 /* main.m */; };
20 20 D264D5A81E6FDE02002CDF41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5A71E6FDE02002CDF41 /* AppDelegate.m */; };
21 21 D264D5AB1E6FDE02002CDF41 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D264D5AA1E6FDE02002CDF41 /* ViewController.m */; };
... ... @@ -31,8 +31,8 @@
31 31 dstPath = "";
32 32 dstSubfolderSpec = 10;
33 33 files = (
34   - D243A77C1E778B54003C573B /* CNLiveChatManager.framework in Embed Frameworks */,
35   - D243A77E1E778B57003C573B /* CNLiveMsgTools.framework in Embed Frameworks */,
  34 + D22551F81E79437C0056B231 /* CNLiveMsgTools.framework in Embed Frameworks */,
  35 + D22551FA1E79437F0056B231 /* CNLiveChatManager.framework in Embed Frameworks */,
36 36 );
37 37 name = "Embed Frameworks";
38 38 runOnlyForDeploymentPostprocessing = 0;
... ... @@ -40,14 +40,14 @@
40 40 /* End PBXCopyFilesBuildPhase section */
41 41  
42 42 /* Begin PBXFileReference section */
  43 + D22551F31E79436D0056B231 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };
  44 + D22551F51E7943740056B231 /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; };
43 45 D231941D1E70101500111C3B /* MessageModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageModel.h; sourceTree = "<group>"; };
44 46 D231941E1E70101500111C3B /* MessageModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageModel.m; sourceTree = "<group>"; };
45 47 D231C8A41E6FFC2700EAC427 /* ChatRoomViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatRoomViewController.h; sourceTree = "<group>"; };
46 48 D231C8A51E6FFC2700EAC427 /* ChatRoomViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatRoomViewController.m; sourceTree = "<group>"; };
47 49 D231C8A71E6FFD3100EAC427 /* PrivateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateViewController.h; sourceTree = "<group>"; };
48 50 D231C8A81E6FFD3100EAC427 /* PrivateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrivateViewController.m; sourceTree = "<group>"; };
49   - D243A7771E778B27003C573B /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };
50   - D243A7791E778B2E003C573B /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; };
51 51 D264D5A01E6FDE02002CDF41 /* CNLiveChatSDKDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNLiveChatSDKDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
52 52 D264D5A41E6FDE02002CDF41 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
53 53 D264D5A61E6FDE02002CDF41 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
... ... @@ -66,10 +66,10 @@
66 66 isa = PBXFrameworksBuildPhase;
67 67 buildActionMask = 2147483647;
68 68 files = (
69   - D243A7781E778B27003C573B /* CNLiveMsgTools.framework in Frameworks */,
70   - D243A77D1E778B57003C573B /* CNLiveMsgTools.framework in Frameworks */,
71   - D243A77A1E778B2E003C573B /* CNLiveChatManager.framework in Frameworks */,
72   - D243A77B1E778B54003C573B /* CNLiveChatManager.framework in Frameworks */,
  69 + D22551F41E79436D0056B231 /* CNLiveMsgTools.framework in Frameworks */,
  70 + D22551F61E7943740056B231 /* CNLiveChatManager.framework in Frameworks */,
  71 + D22551F71E79437C0056B231 /* CNLiveMsgTools.framework in Frameworks */,
  72 + D22551F91E79437F0056B231 /* CNLiveChatManager.framework in Frameworks */,
73 73 );
74 74 runOnlyForDeploymentPostprocessing = 0;
75 75 };
... ... @@ -101,8 +101,8 @@
101 101 D264D5971E6FDE02002CDF41 = {
102 102 isa = PBXGroup;
103 103 children = (
104   - D243A7791E778B2E003C573B /* CNLiveChatManager.framework */,
105   - D243A7771E778B27003C573B /* CNLiveMsgTools.framework */,
  104 + D22551F51E7943740056B231 /* CNLiveChatManager.framework */,
  105 + D22551F31E79436D0056B231 /* CNLiveMsgTools.framework */,
106 106 D264D5A21E6FDE02002CDF41 /* CNLiveChatSDKDemo */,
107 107 D264D5A11E6FDE02002CDF41 /* Products */,
108 108 );
... ...
CNLiveChatSDKDemo/CNLiveChatSDKDemo/AppDelegate.m
... ... @@ -18,10 +18,22 @@
18 18  
19 19 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 20  
21   - // 不要重复初始化
  21 + // 必须初始化 但不要重复初始化
22 22 [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:@"a425987ebc86e352b3373c25d5bd082d0cc248b4043028" appId:@"60_irn9cdak77"];
23 23  
24   - CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170312" name:@"20170312" portrait:@""];
  24 + // 连接服务器,相当于匿名游客身份登录
  25 + // ***** 建议连接服务器操作写在 AppDelegate 里面
  26 +
  27 +// [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
  28 +// NSLog(@"成功");
  29 +// } error:^(CNLiveChatConnectErrorCode errors) {
  30 +// NSLog(@"失败");
  31 +// }];
  32 +
  33 + // 以用户信息登陆 可以在登陆处实现此方法
  34 + // ***** 一次登陆即可,之后无论是网络出现异常或者App有前后台的切换等,SDK都会负责自动重连。
  35 + // ***** 除非您已经手动将连接断开,或者少数无法自动重连的情况,否则您不需要自己再手动重连。
  36 + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170315" name:@"20170315" portrait:@""];
25 37  
26 38 [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) {
27 39  
... ...
CNLiveChatSDKDemo/CNLiveChatSDKDemo/ChatRoomViewController.m
... ... @@ -171,19 +171,23 @@ static NSString *cellId = @&quot;cellId&quot;;
171 171  
172 172 NSLog(@"收到消息类型:%lu,消息ID:%@,消息内容:%@,消息发送者信息:%@",(unsigned long)message.conversationType,message.targetId,message.messageContent,message.userInfo);
173 173  
174   - MessageModel *model = [[MessageModel alloc] init];
175   -
176   - model.message = message.messageContent;
177   - model.userId = message.userInfo.userId;
178   - model.name = message.userInfo.name;
179   - model.portraitUri = message.userInfo.portraitUri;
180   - model.type = message.conversationType;
181   -
182   - [_messageArrayM addObject:model];
183   -
184   - [self.tableView reloadData];
185   -
186   - [self scrollToBottom];
  174 + // 只显示本聊天室信息
  175 + if (message.conversationType == CNLive_ConversationType_CHATROOM && [message.targetId isEqualToString:@"60_7788"]) {
  176 +
  177 + MessageModel *model = [[MessageModel alloc] init];
  178 +
  179 + model.message = message.messageContent;
  180 + model.userId = message.userInfo.userId;
  181 + model.name = message.userInfo.name;
  182 + model.portraitUri = message.userInfo.portraitUri;
  183 + model.type = message.conversationType;
  184 +
  185 + [_messageArrayM addObject:model];
  186 +
  187 + [self.tableView reloadData];
  188 +
  189 + [self scrollToBottom];
  190 + }
187 191 }
188 192  
189 193 - (void)onConnectionStatusChanged:(CNLiveConnectionStatus)status {
... ... @@ -205,6 +209,7 @@ static NSString *cellId = @&quot;cellId&quot;;
205 209  
206 210 - (void)kickedByAnotherDevice {
207 211  
  212 + [_messageArrayM removeAllObjects];
208 213 NSString *userId = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.userId;
209 214 NSLog(@"账号%@在其他设备登陆",userId);
210 215 }
... ...
CNLiveChatSDKDemo/CNLiveChatSDKDemo/PrivateViewController.m
... ... @@ -152,19 +152,22 @@ static NSString *priCellId = @&quot;priCellId&quot;;
152 152  
153 153 NSLog(@"收到消息类型:%lu,消息ID:%@,消息内容:%@,消息发送者信息:%@",(unsigned long)message.conversationType,message.targetId,message.messageContent,message.userInfo);
154 154  
155   - MessageModel *model = [[MessageModel alloc] init];
156   -
157   - model.message = message.messageContent;
158   - model.userId = message.userInfo.userId;
159   - model.name = message.userInfo.name;
160   - model.portraitUri = message.userInfo.portraitUri;
161   - model.type = message.conversationType;
162   -
163   - [_messageArrayM addObject:model];
164   -
165   - [self.tableView reloadData];
166   -
167   - [self scrollToBottom];
  155 + if (message.conversationType == CNLive_ConversationType_PRIVATE) {
  156 +
  157 + MessageModel *model = [[MessageModel alloc] init];
  158 +
  159 + model.message = message.messageContent;
  160 + model.userId = message.userInfo.userId;
  161 + model.name = message.userInfo.name;
  162 + model.portraitUri = message.userInfo.portraitUri;
  163 + model.type = message.conversationType;
  164 +
  165 + [_messageArrayM addObject:model];
  166 +
  167 + [self.tableView reloadData];
  168 +
  169 + [self scrollToBottom];
  170 + }
168 171 }
169 172  
170 173 - (void)onConnectionStatusChanged:(CNLiveConnectionStatus)status {
... ...
CNLiveChatSDKDemo/CNLiveMsgTools.framework/CNLiveMsgTools
No preview for this file type
CNLiveChatSDKDemo/CNLiveMsgTools.framework/Headers/CNLiveMsgManager.h
... ... @@ -17,9 +17,8 @@
17 17 + (instancetype)sharedCNLiveMsgManager;
18 18  
19 19  
20   -- (void)setToolsInfoWithInfoId:(NSString *)infoId
21   - infoName:(NSString *)infoName
22   - infoUrl:(NSString *)infoUrl;
  20 +- (void)setToolsInfoWithInfoName:(NSString *)infoName
  21 + infoUrl:(NSString *)infoUrl;
23 22  
24 23  
25 24 - (NSDictionary *)getToolsInfo;
... ...