iOS 消息收发 UI SDK

个人聊天界面

调用如下代码显示个人聊天界面:

HWChatViewController *controller = [[HWChatViewController alloc] initWithChatID:@"userId" isGroup:NO]; //userId为对方的用户ID
[self.navigationController pushViewController:controller animated:YES];

群聊天界面

调用如下代码显示群聊天界面:

HWChatViewController *controller = [[HWChatViewController alloc] initWithChatID:@"groupId" isGroup:YES]; //groupId为群组ID
[self.navigationController pushViewController:controller animated:YES];

消息收发

可以通过VCloudIMreceiveMessageDelegate属性来监听收到的消息:

[[VCloudIM sharedInstance] setReceiveMessageDelegate:self];

并实现VCloudReceiveMessageDelegate协议:

- (void)onReceiveMessage:(VCloudMessage *)message
{
     //收到消息
}

会话未读消息数

可以通过如下方法获取总的未读消息数:

NSInteger unreadCount = [[VCloudIM sharedInstance] getTotalUnreadCount];

可以获取某个会话的未读消息数:

/// VCloudIM class
 
/*!
 *  @param type 会话类型
 *  @param targetId 会话ID
 *  @return 未读消息数
 */
- (NSInteger)getUnreadCountWithConversationType:(VCloudConversationType)type targetId:(NSString *)targetId;

清除某个会话的未读消息数:

/// VCloudIM class
 
/*!
 *  @param type 会话类型
 *  @param targetId 会话ID
 */
- (void)clearUreadCountWithConversationType:(VCloudConversationType)type targetId:(NSString *)targetId;