BMXChatManager Protocol Reference

Conforms to NSObject
Declared in BMXChatManager.h

Overview

聊天管理器

Instance Methods

ackMessage:

发送已读回执

- (void)ackMessage:(BMXMessageObject *)*message*

Discussion

发送已读回执

Declared In

  • BMXChatManager.h

Example:

- (void)ackMessage:(NSArray<LHMessageModel *> *)modelArray {
    for (LHMessageModel *model in modelArray) {
        if ([model.class isKindOfClass:[LHMessageModel class]]) {
            continue;
        }
        if (!model.isSender && model.messageObjc.isReadAcked == NO) {
            [[[BMXClient sharedClient] chatService] ackMessage:model.messageObjc];
- (void)ackMessagebyModel:(LHMessageModel *)model {
    if (!model.isSender == YES && model.messageObjc.isReadAcked == NO) {
        [[[BMXClient sharedClient] chatService] ackMessage:model.messageObjc];
- (void)ackMessagebyMessageObject:(BMXMessageObject *)messageObject {
    NSString *fromIdStr = [NSString stringWithFormat:@"%lld", messageObject.fromId];
    if (![fromIdStr isEqualToString:self.account.usedId] && messageObject.isRead == NO) {
        [[[BMXClient sharedClient] chatService] ackMessage:messageObject];
- (void)ackMessage:(NSArray<LHMessageModel *> *)modelArray {
    for (LHMessageModel *model in modelArray) {
        if ([model.class isKindOfClass:[LHMessageModel class]]) {
            continue;
        }
        if (!model.isSender && model.messageObjc.isReadAcked == NO) {
            [[[BMXClient sharedClient] chatService] ackMessage:model.messageObjc];
        }
    }
}

ackMessageDelivered:

发送送达回执

- (void)ackMessageDelivered:(BMXMessageObject *)*message*

Discussion

发送送达回执

Declared In

  • BMXChatManager.h

Example:

addChatListener:

添加聊天监听者

- (void)addChatListener:(id<BMXChatServiceProtocol>)*listener*

Discussion

添加聊天监听者

Declared In

  • BMXChatManager.h

Example:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setUpNavItem];
    
    [[[BMXClient sharedClient] chatService] addChatListener:self];

addDelegate:

- (void)addDelegate:(id<BMXChatServiceProtocol>)*aDelegate*

Example:

- (void)registerAPNs {
    [[[BMXClient sharedClient] pushService] start];
    [[[BMXClient sharedClient] pushService] addDelegate:self];
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configCollectionView];
    self.view.clipsToBounds = YES;
    [[[BMXClient sharedClient] chatService] addDelegate:self];
- (void)addIMListener {
    BMXClient *client = [BMXClient sharedClient];
    [[client rosterService] addDelegate:self];
- (void)addIMListener {
    BMXClient *client = [BMXClient sharedClient];
    [[client rosterService] addDelegate:self];
    [[client chatService] addDelegate:self];
- (void)addIMListener {
    BMXClient *client = [BMXClient sharedClient];
    [[client rosterService] addDelegate:self];
    [[client chatService] addDelegate:self];
    [[client userService] addDelegate:self];
- (void)addIMListener {
    BMXClient *client = [BMXClient sharedClient];
    [[client rosterService] addDelegate:self];
    [[client chatService] addDelegate:self];
    [[client userService] addDelegate:self];
    [[client groupService] addDelegate:self];

addDelegate:delegateQueue:

- (void)addDelegate:(id<BMXChatServiceProtocol>)*aDelegate* delegateQueue:(dispatch_queue_t)*aQueue*

Example:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.account = [IMAcountInfoStorage loadObject];
    [self  getMyProfile];
    
    [self setUpNavItem];
    [self setupSubview];
    
    [self loadMessages];
    
    [self scrollToBottomAnimated:NO refresh:NO];
    
    [[[BMXClient sharedClient] chatService] addDelegate:self delegateQueue:dispatch_get_main_queue()];

deleteConversationByConversationId:synchronize:

删除会话

- (void)deleteConversationByConversationId:(NSInteger)*conversationId* synchronize:(BOOL)*synchronize*

Discussion

删除会话

Declared In

  • BMXChatManager.h

Example:

- (void)removeconversation:(BMXConversation *)conversation {
    [[[BMXClient sharedClient]chatService] deleteConversationByConversationId:conversation.conversationId synchronize:YES];

downloadAttachment:

下载附件,下载状态变化和进度通过listener通知

- (void)downloadAttachment:(BMXMessageObject *)*message*

Discussion

下载附件,下载状态变化和进度通过listener通知

Declared In

  • BMXChatManager.h

Example:

        
BMXVoiceAttachment *voiceAtt = (BMXVoiceAttachment *)message.attachment;
        
dbMessageModel.vociePath = voiceAtt.path;
dbMessageModel.content = [NSString stringWithFormat:@"  %d s",voiceAtt.duration];
[self.dataSource insertObject:dbMessageModel atIndex:0];
[self.messages insertObject:dbMessageModel atIndex:0];
        
if (![[NSFileManager defaultManager] fileExistsAtPath:dbMessageModel.vociePath]) {
            
    [[[BMXClient sharedClient] chatService] downloadAttachment:message];
    dbMessageModel.type = MessageBodyType_Location;
    [self.dataSource insertObject:dbMessageModel atIndex:0];
    [self.messages insertObject:dbMessageModel atIndex:0];
        
} else if (message.contentType == BMXContentTypeFile) {
    BMXFileAttachment *fileAtt = (BMXFileAttachment *)message.attachment;
    dbMessageModel.content = fileAtt.displayName ? fileAtt.displayName : @"file";
    dbMessageModel.type = MessageBodyType_File;
    if (![[NSFileManager defaultManager] fileExistsAtPath:fileAtt.path]) {
            
        [[[BMXClient sharedClient] chatService] downloadAttachment:message];
- (void)chatVideoCellBubblePressed:(LHMessageModel *)model {
    if (model.videoPath && ![model.videoPath isKindOfClass:[NSNull class]] && [[NSFileManager defaultManager] fileExistsAtPath:model.videoPath]) {
        [self videoPlay:model.videoPath];
    } else {
        [[[BMXClient sharedClient] chatService] downloadAttachment:model.messageObjc];
            
    dbMessageModel.messageObjc = message;
    [[LHIMDBManager shareManager] insertModel:dbMessageModel];
    NSIndexPath *index = [self insertNewMessageOrTime:dbMessageModel];
    [self.messages addObject:dbMessageModel];
    [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:YES];
            
} else if (message.contentType == BMXContentTypeImage) {
    [[[BMXClient sharedClient] chatService] downloadThumbnail:message strategy:ThirdpartyServerCreate];
            
    [[[BMXClient sharedClient] chatService] downloadAttachment:message];
    [[LHIMDBManager shareManager] insertModel:dbMessageModel];
    NSIndexPath *index = [self insertNewMessageOrTime:dbMessageModel];
    [self.messages addObject:dbMessageModel];
    [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:YES];
            
} else if (message.contentType == BMXContentTypeImage) {
    [[[BMXClient sharedClient] chatService] downloadThumbnail:message strategy:ThirdpartyServerCreate];
            
    [[[BMXClient sharedClient] chatService] downloadAttachment:message];
} else if (message.contentType == BMXContentTypeVoice) {
    [[[BMXClient sharedClient] chatService] downloadAttachment:message];
    dbMessageModel.status = MessageDeliveryState_Delivered;
    dbMessageModel.isSender = NO;
    dbMessageModel.type = MessageBodyType_Location;
    dbMessageModel.messageObjc = message;
    [[LHIMDBManager shareManager] insertModel:dbMessageModel];
    NSIndexPath *index = [self insertNewMessageOrTime:dbMessageModel];
    [self.messages addObject:dbMessageModel];
    [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:YES];
            
} else if (message.contentType == BMXContentTypeFile) {
    [[[BMXClient sharedClient] chatService] downloadAttachment:message];
- (void)setModels:(NSArray *)models {
    LHMessageModel *messagemodel = models.firstObject;
    BMXImageAttachment *attachment = (BMXImageAttachment *)messagemodel.messageObjc.attachment;
    if (attachment.path == nil ||  [@"" isEqualToString:attachment.path] || ![[NSFileManager defaultManager] fileExistsAtPath:attachment.path]) {
        [[[BMXClient sharedClient] chatService] downloadAttachment:messagemodel.messageObjc];

downloadThumbnail:strategy:

下载缩略图,下载状态变化和进度通过listener通知 缩略图生成策略,1 - 第三方服务器生成, 2 - 本地服务器生成,默认值是 1。

- (void)downloadThumbnail:(BMXMessageObject *)*message* strategy:(ThumbnailStrategy)*strategy*

Discussion

下载缩略图,下载状态变化和进度通过listener通知 缩略图生成策略,1 - 第三方服务器生成, 2 - 本地服务器生成,默认值是 1。

Declared In

  • BMXChatManager.h

Example:

} else if (message.contentType == BMXContentTypeImage) {
    dbMessageModel.type = MessageBodyType_Image;
    BMXImageAttachment *imageAtt = (BMXImageAttachment *)message.attachment;
    dbMessageModel.width = imageAtt.pictureSize.width;
    dbMessageModel.height = imageAtt.pictureSize.height;
    dbMessageModel.imageRemoteURL = imageAtt.thumbnailPath;
    [self.dataSource insertObject:dbMessageModel atIndex:0];
    [self.messages insertObject:dbMessageModel atIndex:0];
        
    if (![[NSFileManager defaultManager] fileExistsAtPath:dbMessageModel.imageRemoteURL]) {
        [[[BMXClient sharedClient] chatService] downloadThumbnail:message strategy:ThirdpartyServerCreate];
        dbMessageModel.content = videoAtt.displayName ? videoAtt.displayName : @"video";
        dbMessageModel.type = MessageBodyType_Video;
        
//        MAXLog(@"%f, %f", videoAtt.size.width, videoAtt.size.height)
        dbMessageModel.width = videoAtt.videoSize.width;
        dbMessageModel.height = videoAtt.videoSize.height;
        dbMessageModel.imageRemoteURL = videoAtt.thumbnailPath;
        dbMessageModel.videoPath = videoAtt.path;

        if (![[NSFileManager defaultManager] fileExistsAtPath:dbMessageModel.imageRemoteURL]) {
            [[[BMXClient sharedClient] chatService] downloadThumbnail:message strategy:ThirdpartyServerCreate];
    dbMessageModel.status = MessageDeliveryState_Delivered;
    dbMessageModel.type = MessageBodyType_Text;
            
    dbMessageModel.messageObjc = message;
    [[LHIMDBManager shareManager] insertModel:dbMessageModel];
    NSIndexPath *index = [self insertNewMessageOrTime:dbMessageModel];
    [self.messages addObject:dbMessageModel];
    [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:YES];
            
} else if (message.contentType == BMXContentTypeImage) {
    [[[BMXClient sharedClient] chatService] downloadThumbnail:message strategy:ThirdpartyServerCreate];
    dbMessageModel.type = MessageBodyType_Location;
    dbMessageModel.messageObjc = message;
    [[LHIMDBManager shareManager] insertModel:dbMessageModel];
    NSIndexPath *index = [self insertNewMessageOrTime:dbMessageModel];
    [self.messages addObject:dbMessageModel];
    [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:YES];
            
} else if (message.contentType == BMXContentTypeFile) {
    [[[BMXClient sharedClient] chatService] downloadAttachment:message];
}else if (message.contentType == BMXContentTypeVideo) {
    [[[BMXClient sharedClient] chatService] downloadThumbnail:message strategy:ThirdpartyServerCreate];

forwardMessage:

简单转发消息,用户应当通过BMXMessagse::createForwardMessage()先创建转发消息 *

- (void)forwardMessage:(BMXMessageObject *)*message*

Discussion

简单转发消息,用户应当通过BMXMessagse::createForwardMessage()先创建转发消息 *

Declared In

  • BMXChatManager.h

Example:

- (void)transterSlectedGroup:(BMXGroup *)group {
    BMXMessageObject *m = [[BMXMessageObject alloc] initWithForwardMessage:self.currentMessage.messageObjc fromId:[self.account.usedId longLongValue] toId:group.groupId type:BMXMessageTypeGroup conversationId:group.groupId];
//    m.enableGroupAck = YES;
    [[[BMXClient sharedClient] chatService] forwardMessage:m];
- (void)groupOwnerTransterVCdidSelect:(id)toModel {
    BMXRoster *roster = toModel;
    BMXMessageObject *m = [[BMXMessageObject alloc] initWithForwardMessage:self.currentMessage.messageObjc fromId:[self.account.usedId longLongValue] toId:roster.rosterId type:BMXMessageTypeSingle conversationId:roster.rosterId];
//    m.enableGroupAck = YES;
    [[[BMXClient sharedClient] chatService] forwardMessage:m];

getAllConversationsUnreadCountWithCompletion:

获取所有会话的全部未读数(标记为屏蔽的个人和群组的未读数不统计在内)

- (void)getAllConversationsUnreadCountWithCompletion:(void ( ^ ) ( int count ))*aCompletionBlock*

Parameters

aCompletionBlock
count

Discussion

获取所有会话的全部未读数(标记为屏蔽的个人和群组的未读数不统计在内)

Declared In

  • BMXChatManager.h

Example:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setUpNavItem];
    
    [[[BMXClient sharedClient] chatService] addChatListener:self];
    
    [NetWorkingManager netWorkingManagerWithNetworkStatusListening];
    [self p_addObserver];
    
    [[[BMXClient sharedClient] chatService] getAllConversationsUnreadCountWithCompletion:^(int count) {

getAllConversationsWithCompletion:

获取所有会话

- (void)getAllConversationsWithCompletion:(void ( ^ ) ( NSArray *conversations ))*aCompletionBlock*

Discussion

获取所有会话

Declared In

  • BMXChatManager.h

Example:

- (void)getAllConversations{
    dispatch_async(dispatch_get_main_queue(), ^{
        [HQCustomToast showWating];
    });
    
    [[[BMXClient sharedClient] chatService] getAllConversationsWithCompletion:^(NSArray *conversations) {

getAttachmentDir

获取附件保存路径

- (NSString *)getAttachmentDir

Discussion

获取附件保存路径

Declared In

  • BMXChatManager.h

Example:

- (NSString *)recorderMainPath
{
    
    
//    NSString* dataDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:@"CWVoice"];

    NSString *path = [[[[BMXClient sharedClient] chatService] getAttachmentDir] stringByAppendingPathComponent:kChildPath];
- (void)moreViewFileAction:(LHChatBarMoreView *)moreView {
     // 进入页面管理,选择文件
    
    if (SystemVersion >=  11.0) {
        [self displayChooseFileViewController];
    } else {
        ICDocumentViewController *docVC = [[ICDocumentViewController alloc] init];
        docVC.delegate = self;
        NSString *filePath = [[[[BMXClient sharedClient] chatService] getAttachmentDir] stringByAppendingPathComponent:@"file"];

getAttachmentDirForConversationWith:

获取会话的附件保存路径

- (NSString *)getAttachmentDirForConversationWith:(NSString *)*conversationId*

Discussion

获取会话的附件保存路径

Declared In

  • BMXChatManager.h

Example:

getGroupAckMessageUnreadUserIdListWithMessage:completion:

获取发送的群组消息未读用户id列表

- (void)getGroupAckMessageUnreadUserIdListWithMessage:(BMXMessageObject *)*message* completion:(void ( ^ ) ( NSArray *groupMemberIdList , BMXError *error ))*aCompletionBlock*

Parameters

message
需要获取未读用户id列表的消息

aCompletionBlock
对该条消息未读的用户id列表,初始传入为空列表

Discussion

获取发送的群组消息未读用户id列表

Declared In

  • BMXChatManager.h

Example:

- (void)getUnreadRoster {
    MAXLog(@"拉取未读群成员");
    
    
    [[[BMXClient sharedClient] chatService] getGroupAckMessageUnreadUserIdListWithMessage:self.message completion:^(NSArray *groupMemberIdList, BMXError *error) {

getGroupAckMessageUserIdListWithMessage:completion:

获取发送的群组消息已读用户id列表

- (void)getGroupAckMessageUserIdListWithMessage:(BMXMessageObject *)*message* completion:(void ( ^ ) ( NSArray *groupMemberIdList , BMXError *error ))*aCompletionBlock*

Parameters

message
需要获取已读用户id列表的消息

aCompletionBlock
对该条消息已读的用户id列表,初始传入为空列表

Discussion

获取发送的群组消息已读用户id列表

Declared In

  • BMXChatManager.h

Example:

- (void)getAlreadyRoster {
    [[[BMXClient sharedClient] chatService] getGroupAckMessageUserIdListWithMessage:self.message completion:^(NSArray *groupMemberIdList, BMXError *error) {

getMessage:completion:

读取一条消息

- (void)getMessage:(NSInteger)*messageId* completion:(void ( ^ ) ( BMXMessageObject *message , BMXError *error ))*aCompletionBlock*

Discussion

读取一条消息

Declared In

  • BMXChatManager.h

Example:

insetMessages:completion:

插入消息

- (void)insetMessages:(NSArray<BMXMessageObject*> *)*list* completion:(void ( ^ ) ( BMXError *error ))*aCompletionBlock*

Discussion

插入消息

Declared In

  • BMXChatManager.h

Example:

openConversation:type:createIfNotExist:

打开一个会话

- (BMXConversation *)openConversation:(NSInteger)*conversationId* type:(BMXConversationType)*type* createIfNotExist:(bool)*create*

Discussion

打开一个会话

Declared In

  • BMXChatManager.h

Example:

- (void)loadMessages {
    BMXConversation *conversation;
    if (self.messageType == BMXConversationGroup) {
        self.conversationId =  self.conversationId ?self.conversationId : (NSInteger)self.currentGroup.groupId;
        BMXConversation *groupConversation = [[[BMXClient sharedClient] chatService] openConversation:self.conversationId type:BMXConversationGroup createIfNotExist:YES];
- (void)loadMessages {
    BMXConversation *conversation;
    if (self.messageType == BMXConversationGroup) {
        self.conversationId =  self.conversationId ?self.conversationId : (NSInteger)self.currentGroup.groupId;
        BMXConversation *groupConversation = [[[BMXClient sharedClient] chatService] openConversation:self.conversationId type:BMXConversationGroup createIfNotExist:YES];
        
        conversation = groupConversation;
    } else {
        self.conversationId = self.conversationId ? self.conversationId: (NSInteger)self.currentRoster.rosterId;
        BMXConversation *singleConversation = [[[BMXClient sharedClient] chatService] openConversation:self.conversationId type:BMXConversationSingle createIfNotExist:YES];
- (void)receiveNewMessage:(BMXMessageObject *)message {
    long long conversationId = message.conversationId;
    BOOL hasConversation = NO;
    NSArray *temp = [self.conversatonList copy];
    for (BMXConversation *conversation in temp) {
        if (conversationId == conversation.conversationId) {
            hasConversation  = YES;
            [self getProfiletWithConversations:temp];
            break;
        }
    }
    if (!hasConversation) {
        BMXConversationType type;
        if (message.messageType == BMXMessageTypeSingle) {
            type = BMXConversationSingle;
        } else {
            type = BMXConversationGroup;
        }
        BMXConversation *conversation = [[[BMXClient sharedClient] chatService] openConversation:conversationId type:type createIfNotExist:YES];
    }
}
if (!hasConversation) {
        
    BMXConversationType type;
    if (message.messageType == BMXMessageTypeSingle) {
        type = BMXConversationSingle;
    } else {
        type = BMXConversationGroup;
    }
    BMXConversation *conversation = [[[BMXClient sharedClient] chatService] openConversation:conversationId type:type createIfNotExist:YES];

readAllMessage:

标记此消息及之前全部消息为已读,该消息同步到当前用户的所有设备

- (void)readAllMessage:(BMXMessageObject *)*message*

Discussion

标记此消息及之前全部消息为已读,该消息同步到当前用户的所有设备

Declared In

  • BMXChatManager.h

Example:

    [self.navigationController pushViewController:chatVC animated:YES];
} else if ([NSStringFromClass([self.profileArray[indexPath.row] class]) isEqualToString:@"BMXGroup"]) {

    BMXGroup *group = self.profileArray[indexPath.row];
    chatVC = [[LHChatVC alloc] initWithGroupChat:(BMXGroup *)group messageType:BMXMessageTypeGroup];
        
    BMXConversation *conversation = self.conversatonList[indexPath.row];
    if (conversation.unreadNumber > 0) {
            
        if (conversation.lastMessage) {
            [[[BMXClient sharedClient] chatService] readAllMessage:conversation.lastMessage];
    }
        
    chatVC.delegate = self;
    [chatVC setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:chatVC animated:YES];
} else if ([self.profileArray[indexPath.row] isKindOfClass:[NSDictionary class]]) {
    BMXConversation *conversation = self.conversatonList[indexPath.row];
    if (conversation.unreadNumber > 0) {
            
        if (conversation.lastMessage) {
            [[[BMXClient sharedClient] chatService] readAllMessage:conversation.lastMessage];

readCancel:

标记此消息为未读,该消息同步到当前用户的所有设备

- (void)readCancel:(BMXMessageObject *)*message*

Discussion

标记此消息为未读,该消息同步到当前用户的所有设备

Declared In

  • BMXChatManager.h

Example:

- (void)setUnread {
    [[[BMXClient sharedClient] chatService] readCancel:self.currentMessage.messageObjc];
handler:^(UIAlertAction * action) {
    if (message.messageObjc) {
        //
        [[[BMXClient sharedClient] chatService] readCancel:message.messageObjc];

recallMessage:completion:

撤回消息,消息状态变化会通过listener通知 *

- (void)recallMessage:(BMXMessageObject *)*message* completion:(void ( ^ ) ( BMXMessageObject *message , BMXError *error ))*aCompletionBlock*

Discussion

撤回消息,消息状态变化会通过listener通知 *

Declared In

  • BMXChatManager.h

Example:

- (void)recallMessage {
    [[UIMenuController sharedMenuController] setMenuVisible:NO animated:YES];
    [[[BMXClient sharedClient] chatService] recallMessage:self.currentMessage.messageObjc completion:nil];

removeChatListener:

移除聊天监听者

- (void)removeChatListener:(id<BMXChatServiceProtocol>)*listener*

Discussion

移除聊天监听者

Declared In

  • BMXChatManager.h

Example:

removeDelegate:

- (void)removeDelegate:(id<BMXChatServiceProtocol>)*aDelegate*

Example:

removeMessage:synchronizeDeviceForce:

删除此消息,该消息同步到当前用户的其它设备

- (void)removeMessage:(BMXMessageObject *)*message* synchronizeDeviceForce:(BOOL)*synchronizeDeviceForce*

Discussion

删除此消息,该消息同步到当前用户的其它设备

Declared In

  • BMXChatManager.h

Example:

- (void)deleteMessage {
    [[UIMenuController sharedMenuController] setMenuVisible:NO animated:YES];
    [[[BMXClient sharedClient] chatService] removeMessage:self.currentMessage.messageObjc synchronizeDeviceForce:YES];

resendMessage:completion:

重新发送消息,消息状态变化会通过listener通知 *

- (void)resendMessage:(BMXMessageObject *)*message* completion:(void ( ^ ) ( BMXMessageObject *message , BMXError *error ))*aCompletionBlock*

Discussion

重新发送消息,消息状态变化会通过listener通知 *

Declared In

  • BMXChatManager.h

Example:

- (void)retryButtonPressed:(UIButton *)sender {
    [self routerEventWithName:kRouterEventChatResendEventName
                     userInfo:@{kShouldResendCell : self}];
    self.self.messageModel.status = MessageDeliveryState_Delivering;
    [self layoutSubviews];
    
    [[[BMXClient sharedClient] chatService] resendMessage: self.messageModel.messageObjc completion:^(BMXMessageObject *message, BMXError *error) {

retrieveHistoryBMXconversation:msgId:size:completion:

拉取历史消息

- (void)retrieveHistoryBMXconversation:(BMXConversation *)*conversation* msgId:(long long)*msgId* size:(NSUInteger)*size* completion:(void ( ^ ) ( NSArray *messageListms , BMXError *error ))*aCompletionBlock*

Discussion

拉取历史消息

Declared In

  • BMXChatManager.h

Example:

                });
            }
        }];
    }else {
        self.deImage = image;
    }
        
}
self.conversation = conversation;
    
[[[BMXClient sharedClient] chatService] retrieveHistoryBMXconversation:self.conversation msgId:0 size:10 completion:^(NSArray *messageListms, BMXError *error) {
- (void)getHistoryMessage {
    BMXMessageObject *firstMessage;
    for (int i = 0; i < self.dataSource.count;i++) {
        LHMessageModel *messageModel = self.dataSource[i];
        if ([messageModel isKindOfClass:[LHMessageModel class]]) {
            firstMessage = messageModel.messageObjc;
            break;
        }
    }
    long long firstMessageId = firstMessage? firstMessage.msgId : 0;
    
    [[[BMXClient sharedClient] chatService] retrieveHistoryBMXconversation:self.conversation msgId:firstMessageId size:10 completion:^(NSArray *messageListms, BMXError *error) {
- (void)loadMessages {
    [[[BMXClient sharedClient] chatService] retrieveHistoryBMXconversation:self.conversation msgId:0 size:10 completion:^(NSArray *messageListms, BMXError *error) {

searchMessagesByKeyWords:refTime:size:directionType:completion:

搜索消息

- (void)searchMessagesByKeyWords:(NSString *)*keywords* refTime:(NSTimeInterval)*refTime* size:(NSUInteger)*size* directionType:(BMXMessageDirection)*directionType* completion:(void ( ^ ) ( NSArray *array , BMXError *error ))*aCompletionBlock*

Discussion

搜索消息

Declared In

  • BMXChatManager.h

Example:

- (void)searchContentWith:(NSString *)keywords {
    if (self.isConversation == YES) {
        if (self.searchContentType == BMXContentTypeText) {
            [self.conversation searchMessagesByKeyWords:keywords refTime:0 size:100 directionType:BMXMessageDirectionUp completion:^(NSArray<BMXMessageObject *> * _Nonnull messageList, BMXError * _Nonnull error) {
- (void)searchContentWith:(NSString *)keywords {
    if (self.isConversation == YES) {
        if (self.searchContentType == BMXContentTypeText) {
            [self.conversation searchMessagesByKeyWords:keywords refTime:0 size:100 directionType:BMXMessageDirectionUp completion:^(NSArray<BMXMessageObject *> * _Nonnull messageList, BMXError * _Nonnull error) {
                [self dataHandleMessages:messageList];

            }];
        }
    } else {
        [[[BMXClient sharedClient] chatService] searchMessagesByKeyWords:keywords refTime:0 size:100 directionType:BMXMessageDirectionUp completion:^(NSArray *array, BMXError *error) {

sendMessage:

发送消息,消息状态变化会通过listener通知 *

- (void)sendMessage:(BMXMessageObject *)*message*

Discussion

发送消息,消息状态变化会通过listener通知 *

Declared In

  • BMXChatManager.h

Example:

alertView.btnClickBlock = ^{
        
    UIImage *image = contentImg;
    NSData *imageData = UIImageJPEGRepresentation(image,1.0f);
    NSData *thumImageData =  UIImageJPEGRepresentation(image,1.0f);
    BMXImageAttachment *imageAttachment = [[BMXImageAttachment alloc] initWithData:imageData thumbnailData:thumImageData imageSize:image.size conversationId:[NSString stringWithFormat:@"%lld",group.groupId]];
    imageAttachment.pictureSize = CGSizeMake(image.size.width, image.size.height);
    IMAcount *account = [IMAcountInfoStorage loadObject];
    BMXMessageObject *messageObject = [[BMXMessageObject alloc] initWithBMXMessageAttachment:imageAttachment fromId:[account.usedId longLongValue] toId:group.groupId type:BMXMessageTypeGroup conversationId:group.groupId];
    messageObject.contentType = BMXContentTypeImage;
    if (messageObject) {
        [[[BMXClient sharedClient] chatService] sendMessage:messageObject];
- (void)sendTypingMessage:(NSDictionary *)configdic {
    BMXMessageObject *messageObject = [[BMXMessageObject alloc] initWithBMXMessageText:@""
                                                                                fromId:[self.account.usedId longLongValue]
                                                                                  toId:self.currentRoster.rosterId
                                                                                  type:BMXMessageTypeSingle
                                                                        conversationId:self.currentRoster.rosterId];
    messageObject.extensionJson = [NSString jsonStringWithDictionary:configdic];
    messageObject.qos = DeliveryQosModeAtMostOnce;
    [[[BMXClient sharedClient] chatService] sendMessage:messageObject];
    self.lastTime = [NSString stringWithFormat:@"%f",messageModel.messageObjc.serverTimestamp * 0.001];
    [self insertNewMessageOrTime:time];
    //        self.lastTime = time;
}
NSIndexPath *index = [self insertNewMessageOrTime:messageModel];
[self.messages addObject:messageModel];
[self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:YES];
    
if (messageObject) {
    messageObject.clientTimestamp = [messageModel.date longLongValue];
    [[[BMXClient sharedClient] chatService] sendMessage:messageObject];
_chatBarView.sendContent = ^(LHContentModel *content) {
    [weakSelf sendMessage:content];
alertView.btnClickBlock = ^{
        
        UIImage *image = contentImg;
        NSData *imageData = UIImageJPEGRepresentation(image,1.0f);
        NSData *thumImageData =  UIImageJPEGRepresentation(image,1.0f);
        BMXImageAttachment *imageAttachment = [[BMXImageAttachment alloc] initWithData:imageData thumbnailData:thumImageData imageSize:image.size conversationId:[NSString stringWithFormat:@"%lld",roster.rosterId]];
        imageAttachment.pictureSize = CGSizeMake(image.size.width, image.size.height);
        IMAcount *account = [IMAcountInfoStorage loadObject];
    BMXMessageObject *messageObject = [[BMXMessageObject alloc] initWithBMXMessageAttachment:imageAttachment fromId:[account.usedId longLongValue] toId:roster.rosterId type:BMXMessageTypeSingle conversationId:roster.rosterId];
        messageObject.contentType = BMXContentTypeImage;
    if (messageObject) {
        [[[BMXClient sharedClient] chatService] sendMessage:messageObject];
- (void)sendMessage:(LHContentModel *)content {
    if (content.words && content.words.length) {
        // 文字类型
        [self p_configsendMessage:content.words type:MessageBodyType_Text duartion:0];
    }
    if (!content.photos && !content.photos.photos.count) return;
    // 图片类型
    [content.photos.photos enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL * stop) {
        [self p_configsendMessage:image type:MessageBodyType_Image duartion:0];
    }];
}

transferingNum

上传或下载中的文件数

- (int)transferingNum

Discussion

上传或下载中的文件数

Declared In

  • BMXChatManager.h

Example:

© 2019-2022 美信拓扑 | 官网 该文件修订时间: 2022-09-21 11:43:07

results matching ""

    No results matching ""