HyphenateSDK  3.6.1
构造函数 | 属性 | 所有成员列表
EMConversation类 参考

#import <EMConversation.h>

类 EMConversation 继承关系图:

构造函数

(EMMessage *) - lastReceivedMessage
 
(void) - insertMessage:error:
 
(void) - appendMessage:error:
 
(void) - deleteMessageWithId:error:
 
(void) - deleteAllMessages:
 
(void) - updateMessageChange:error:
 
(void) - markMessageAsReadWithId:error:
 
(void) - markAllMessagesAsRead:
 
(EMMessage *) - loadMessageWithId:error:
 
(void) - loadMessagesStartFromId:count:searchDirection:completion:
 
(void) - loadMessagesWithType:timestamp:count:fromUser:searchDirection:completion:
 
(void) - loadMessagesWithKeyword:timestamp:count:fromUser:searchDirection:completion:
 
(void) - loadMessagesFrom:to:count:completion:
 
(BOOL) - insertMessage:
 
(BOOL) - appendMessage:
 
(BOOL) - deleteMessageWithId:
 
("Use -deleteAllMessages:") - __deprecated_msg
 
(BOOL) - updateMessage:
 
(BOOL) - markMessageAsReadWithId:
 
("Use -markAllMessagesAsRead:") - __deprecated_msg
 
("setExt: will update extend properties to DB") - __deprecated_msg
 
(EMMessage *) - loadMessageWithId:
 
(NSArray *) - loadMoreMessagesFromId:limit:direction:
 
(NSArray *) - loadMoreMessagesWithType:before:limit:from:direction:
 
(NSArray *) - loadMoreMessagesContain:before:limit:from:direction:
 
(NSArray *) - loadMoreMessagesFrom:to:maxCount:
 
("Use -lastReceivedMessage") - __deprecated_msg
 

属性

NSString * conversationId
 
EMConversationType type
 
int unreadMessagesCount
 
NSDictionary * ext
 
EMMessagelatestMessage
 

详细描述

聊天会话

函数文档

- ("Use -)deleteAllMessages:

删除该会话所有消息

返回
是否成功

将所有未读消息设置为已读

返回
是否成功
- "setExt:

更新会话扩展属性到DB

返回
是否成功
- ("Use -lastReceivedMessage") __deprecated_msg

收到的对方发送的最后一条消息

返回
消息实例
- (BOOL) appendMessage: ("Use -appendMessage:error:")  __deprecated_msg

插入一条消息到会话尾部,消息的conversationId应该和会话的conversationId一致,消息会被插入DB,并且更新会话的latestMessage等属性

参数
aMessage消息实例
返回
是否成功
- (void) appendMessage: (EMMessage *)  aMessage
error: (EMError **)  pError 

插入一条消息到会话尾部,消息的conversationId应该和会话的conversationId一致,消息会被插入DB,并且更新会话的latestMessage等属性

参数
aMessage消息实例
pError错误信息
- (void) deleteAllMessages: (EMError **)  pError

删除该会话所有消息,同时清除内存和数据库中的消息

参数
pError错误信息
- (BOOL) deleteMessageWithId: ("Use -deleteMessageWithId:error:")  __deprecated_msg

删除一条消息

参数
aMessageId要删除消失的ID
返回
是否成功
- (void) deleteMessageWithId: (NSString *)  aMessageId
error: (EMError **)  pError 

删除一条消息

参数
aMessageId要删除消失的ID
pError错误信息
- (BOOL) insertMessage: ("Use -insertMessage:error:")  __deprecated_msg

插入一条消息,消息的conversationId应该和会话的conversationId一致,消息会被插入DB,并且更新会话的latestMessage等属性

参数
aMessage消息实例
返回
是否成功
- (void) insertMessage: (EMMessage *)  aMessage
error: (EMError **)  pError 

插入一条消息,消息的conversationId应该和会话的conversationId一致,消息会被插入DB,并且更新会话的latestMessage等属性 insertMessage 会更新对应Conversation里的latestMessage Method EMConversation insertMessage:error: = EMChatManager importMsessage:completion: + update conversation latest message

参数
aMessage消息实例
pError错误信息
- (EMMessage *) lastReceivedMessage

收到的对方发送的最后一条消息,也是会话里的最新消息

返回
消息实例
- (void) loadMessagesFrom: (long long)  aStartTimestamp
to: (long long)  aEndTimestamp
count: (int)  aCount
completion: (void(^)(NSArray *aMessages, EMError *aError))  aCompletionBlock 

从数据库获取指定时间段内的消息,取到的消息按时间排序,为了防止占用太多内存,用户应当制定加载消息的最大数

参数
aStartTimestamp毫秒级开始时间
aEndTimestamp结束时间
aCount加载消息最大数
aCompletionBlock完成的回调
- (void) loadMessagesStartFromId: (NSString *)  aMessageId
count: (int)  aCount
searchDirection: (EMMessageSearchDirection)  aDirection
completion: (void(^)(NSArray *aMessages, EMError *aError))  aCompletionBlock 

从数据库获取指定数量的消息,取到的消息按时间排序,并且不包含参考的消息,如果参考消息的ID为空,则从最新消息取

参数
aMessageId参考消息的ID
count获取的条数
aDirection消息搜索方向
aCompletionBlock完成的回调
- (void) loadMessagesWithKeyword: (NSString *)  aKeyword
timestamp: (long long)  aTimestamp
count: (int)  aCount
fromUser: (NSString *)  aSender
searchDirection: (EMMessageSearchDirection)  aDirection
completion: (void(^)(NSArray *aMessages, EMError *aError))  aCompletionBlock 

从数据库获取包含指定内容的消息,取到的消息按时间排序,如果参考的时间戳为负数,则从最新消息向前取,如果aCount小于等于0当作1处理

参数
aKeywords搜索关键字,如果为空则忽略
aTimestamp参考时间戳
aCount获取的条数
aSender消息发送方,如果为空则忽略
aDirection消息搜索方向
aCompletionBlock完成的回调
- (void) loadMessagesWithType: (EMMessageBodyType)  aType
timestamp: (long long)  aTimestamp
count: (int)  aCount
fromUser: (NSString *)  aUsername
searchDirection: (EMMessageSearchDirection)  aDirection
completion: (void(^)(NSArray *aMessages, EMError *aError))  aCompletionBlock 

从数据库获取指定类型的消息,取到的消息按时间排序,如果参考的时间戳为负数,则从最新消息取,如果aCount小于等于0当作1处理

参数
aType消息类型
aTimestamp参考时间戳
aCount获取的条数
aUsername消息发送方,如果为空则忽略
aDirection消息搜索方向
aCompletionBlock完成的回调
- (EMMessage *) loadMessageWithId: ("Use -loadMessageWithId:error:")  __deprecated_msg

获取指定ID的消息

参数
aMessageId消息ID
返回
消息
- (EMMessage *) loadMessageWithId: (NSString *)  aMessageId
error: (EMError **)  pError 

获取指定ID的消息

参数
aMessageId消息ID
pError错误信息
- (NSArray *) loadMoreMessagesContain: (NSString *)  aKeywords
before: (long long)  aTimestamp
limit: (int)  aLimit
from: (NSString *)  aSender
direction: ("Use -loadMessagesContainKeywords:timestamp:count:fromUser:searchDirection:completion:")  __deprecated_msg 

从数据库获取包含指定内容的消息,取到的消息按时间排序,如果参考的时间戳为负数,则从最新消息向前取,如果aLimit是负数,则获取所有符合条件的消息

参数
aKeywords搜索关键字,如果为空则忽略
aTimestamp参考时间戳
aLimit获取的条数
aSender消息发送方,如果为空则忽略
aDirection消息搜索方向
返回
消息列表<EMMessage>
- (NSArray *) loadMoreMessagesFrom: (long long)  aStartTimestamp
to: (long long)  aEndTimestamp
maxCount: ("Use -loadMessagesFrom:to:count:completion:")  __deprecated_msg 

从数据库获取指定时间段内的消息,取到的消息按时间排序,为了防止占用太多内存,用户应当制定加载消息的最大数

参数
aStartTimestamp毫秒级开始时间
aEndTimestamp结束时间
aMaxCount加载消息最大数
返回
消息列表<EMMessage>
- (NSArray *) loadMoreMessagesFromId: (NSString *)  aMessageId
limit: (int)  aLimit
direction: ("Use -loadMessagesStartFromId:count:searchDirection:completion:")  __deprecated_msg 

从数据库获取指定数量的消息,取到的消息按时间排序,并且不包含参考的消息,如果参考消息的ID为空,则从最新消息向前取

参数
aMessageId参考消息的ID
aLimit获取的条数
aDirection消息搜索方向
返回
消息列表<EMMessage>
- (NSArray *) loadMoreMessagesWithType: (EMMessageBodyType)  aType
before: (long long)  aTimestamp
limit: (int)  aLimit
from: (NSString *)  aSender
direction: ("Use -loadMessagesWithType:timestamp:count:fromUser:searchDirection:completion:")  __deprecated_msg 

从数据库获取指定类型的消息,取到的消息按时间排序,如果参考的时间戳为负数,则从最新消息向前取,如果aLimit是负数,则获取所有符合条件的消息

参数
aType消息类型
aTimestamp参考时间戳
aLimit获取的条数
aSender消息发送方,如果为空则忽略
aDirection消息搜索方向
返回
消息列表<EMMessage>
- (void) markAllMessagesAsRead: (EMError **)  pError

将所有未读消息设置为已读

参数
pError错误信息
- (BOOL) markMessageAsReadWithId: ("Use -markMessageAsReadWithId:error:")  __deprecated_msg

将消息设置为已读

参数
aMessageId要设置消息的ID
返回
是否成功
- (void) markMessageAsReadWithId: (NSString *)  aMessageId
error: (EMError **)  pError 

将消息设置为已读

参数
aMessageId要设置消息的ID
pError错误信息
- (BOOL) updateMessage: ("Use -updateMessageChange:error:")  __deprecated_msg

更新一条消息,不能更新消息ID,消息更新后,会话的latestMessage等属性进行相应更新

参数
aMessage要更新的消息
返回
是否成功
- (void) updateMessageChange: (EMMessage *)  aMessage
error: (EMError **)  pError 

更新本地的消息,不能更新消息ID,消息更新后,会话的latestMessage等属性进行相应更新

参数
aMessage要更新的消息
pError错误信息

属性说明

- (NSString*) conversationId
readnonatomiccopy

会话ID 对于单聊类型,会话ID同时也是对方用户的名称。 对于群聊类型,会话ID同时也是对方群组的ID,并不同于群组的名称。 对于聊天室类型,会话ID同时也是聊天室的ID,并不同于聊天室的名称。 对于HelpDesk类型,会话ID与单聊类型相同,是对方用户的名称。

- (NSDictionary*) ext
readwritenonatomiccopy

会话扩展属性

- (EMMessage*) latestMessage
readnonatomicstrong

会话最新一条消息

- (EMConversationType) type
readnonatomicassign

会话类型

- (int) unreadMessagesCount
readnonatomicassign

对话中未读取的消息数量


该类的文档由以下文件生成: