* Load messages with specified keyword, returning messages are sorted by receiving timestamp. If reference timestamp is negative, load from the latest messages; if message count is negative, count deal with 1 and load one message that meet the condition.
*
* @param aKeywords Search content, will ignore it if it's empty
* @param aTimestamp Reference timestamp
* @param aCount Count of messages to load
* @param aSender Message sender (optional)
* @param aDirection Message search direction
* @param aCompletionBlock The callback block of completion
18 个回复
[已注销]
/*!
* \~chinese
* 从数据库获取包含指定内容的消息,取到的消息按时间排序,如果参考的时间戳为负数,则从最新消息向前取,如果aCount小于等于0当作1处理
*
* @param aKeywords 搜索关键字,如果为空则忽略
* @param aTimestamp 参考时间戳
* @param aCount 获取的条数
* @param aSender 消息发送方,如果为空则忽略
* @param aDirection 消息搜索方向
* @param aCompletionBlock 完成的回调
*
* \~english
* Load messages with specified keyword, returning messages are sorted by receiving timestamp. If reference timestamp is negative, load from the latest messages; if message count is negative, count deal with 1 and load one message that meet the condition.
*
* @param aKeywords Search content, will ignore it if it's empty
* @param aTimestamp Reference timestamp
* @param aCount Count of messages to load
* @param aSender Message sender (optional)
* @param aDirection Message search direction
* @param aCompletionBlock The callback block of completion
*
*/
- (void)loadMessagesWithKeyword:(NSString*)aKeyword
timestamp:(long long)aTimestamp
count:(int)aCount
fromUser:(NSString*)aSender
searchDirection:(EMMessageSearchDirection)aDirection
completion:(void (^)(NSArray *aMessages, EMError *aError))aCompletionBlock;这个方法
@柠檬不太酸
_conversation = [[EMClient sharedClient].chatManager getConversation:self.conversation type:EMConversationTypeChat createIfNotExist:NO];
在会话列表界面 会话ID和会话类型 这两个参数 要怎么写
[self.conversation loadMessagesWithKeyword:searchBar.text timestamp:[self.datePicker.date timeIntervalSince1970]*1000 count:SEARCHMESSAGE_PAGE_SIZE fromUser:self.textField.text searchDirection:EMMessageSearchDirectionUp completion:^(NSArray *aMessages, EMError *aError) {
ConversationListController *strongSelf = weakSelf;
if (strongSelf) {
if([aMessages count]<SEARCHMESSAGE_PAGE_SIZE) {
strongSelf.hasMore = NO;
} else {
strongSelf.hasMore = YES;
}
[strongSelf.searchController.resultsSource removeAllObjects];
[strongSelf.searchController.resultsSource addObjectsFromArray:[[aMessages reverseObjectEnumerator] allObjects]];
[strongSelf.searchController.searchResultsTableView reloadData];
}
}];
[已注销]
@柠檬不太酸
[已注销]
@柠檬不太酸
@柠檬不太酸
EMConversation * Conversation = self.conversationsArray[i];
self.conversation = [[EMClient sharedClient].chatManager getConversation:Conversation.conversationId type:Conversation.type createIfNotExist:NO];
__weak typeof(self) weakSelf = self;
[self.conversation loadMessagesWithKeyword:searchBar.text timestamp:[self.datePicker.date timeIntervalSince1970]*1000 count:SEARCHMESSAGE_PAGE_SIZE fromUser:self.textField.text searchDirection:EMMessageSearchDirectionUp completion:^(NSArray *aMessages, EMError *aError) {
ConversationListController *strongSelf = weakSelf;
if (strongSelf) {
if([aMessages count]<SEARCHMESSAGE_PAGE_SIZE) {
strongSelf.hasMore = NO;
}else {
strongSelf.hasMore = YES;
}
[strongSelf.searchController.resultsSource removeAllObjects];
[strongSelf.searchController.resultsSource addObjectsFromArray:[[aMessages reverseObjectEnumerator] allObjects]];
[strongSelf.searchController.searchResultsTableView reloadData];
}
}];
}
[已注销]
fromUser:传 nil 时间戳单位要求是毫秒,
@柠檬不太酸
[已注销]
@柠檬不太酸
[已注销]
然后SearchChatViewController 在这个类 98行 加上这段代码//MARK:搜索崩溃处理
[strongSelf.messsagesSource removeAllObjects];
[strongSelf.dataArray removeAllObjects];
NSArray *formattedMessages = [self formatMessages:aMessages];
@柠檬不太酸
@柠檬不太酸
[已注销]
@柠檬不太酸
[已注销]
[已注销]