BMXChatServiceProtocol Protocol Reference

Conforms to NSObject
Declared in BMXChatServiceProtocol.h

Instance Methods

conversationDidCreatedConversation:message:

本地创建新会话成功

- (void)conversationDidCreatedConversation:(BMXConversation *)*conversation* message:(BMXMessageObject *)*message*

Parameters

conversation
新创建的本地会话

message
会话的最新消息,存在返回不存在返回为空

Discussion

本地创建新会话成功

Declared In

  • BMXChatServiceProtocol.h

Example:

conversationDidDeletedConversationId:error:

删除会话

- (void)conversationDidDeletedConversationId:(NSInteger)*conversationId* error:(BMXError *)*error*

Parameters

conversationId
删除的本地会话id

error
状态错误码

Discussion

删除会话

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)conversationDidDeletedConversationId:(NSInteger)conversationId error:(BMXError *)error {
    MAXLog(@"会话已被删除");
}

conversationTotalCountChanged:

更新总未读数

- (void)conversationTotalCountChanged:(NSInteger)*unreadCount*

Parameters

unreadCount
未读数

Discussion

更新总未读数

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)conversationTotalCountChanged:(NSInteger)unreadCount {
    
    [self showUnReadNumber:(int)unreadCount];
}

loadAllConversationDidFinished

已经加载完未读会话列表

- (void)loadAllConversationDidFinished

Discussion

已经加载完未读会话列表

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)loadAllConversationDidFinished {
    MAXLog(@"all");
//    self.conversationFinish = YES;
    [self getAllConversations];
}

messageAttachmentStatusDidChanged:error:percent:

附件下载状态发生变化

- (void)messageAttachmentStatusDidChanged:(BMXMessageObject *)*message* error:(BMXError *)*error* percent:(int)*percent*

Discussion

附件下载状态发生变化

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)messageAttachmentStatusDidChanged:(BMXMessageObject *)message
                                    error:(BMXError*)error
                                  percent:(int)percent {
    if (message.messageType == BMXMessageTypeGroup) {
        if (self.conversation.type != BMXMessageTypeGroup || message.toId != self.conversation.conversationId) {
            return;
        }
    } else {
        if (message.fromId  != self.conversation.conversationId || message.messageType != BMXMessageTypeSingle) {
            if (message.fromId == [self.account.usedId longLongValue] && message.toId == self.conversation.conversationId) {
                
            } else {
                return;
            }
        }
    }
    
    if (percent == 101 && !error ) {

        NSString *date =  [NSString stringWithFormat:@"%lld",  message.serverTimestamp];
- (void)messageAttachmentStatusDidChanged:(BMXMessageObject *)message error:(BMXError *)error percent:(int)percent {
    
//    MAXLog(@"走了吗");
    if (!error && percent == 101) {
        self.messageObject = message;
        _models = @[self.messageObject];
        [_collectionView reloadData];
    } else if (error) {
        self.messageObject = message;
        _models = @[self.messageObject];
        [_collectionView reloadData];
    }
}

messageAttachmentUploadProgressChanged:percent:

附件上传进度发送变化

- (void)messageAttachmentUploadProgressChanged:(BMXMessageObject *)*message* percent:(int)*percent*

Discussion

附件上传进度发送变化

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)messageAttachmentUploadProgressChanged:(BMXMessageObject *)message percent:(int)percent {
    MAXLog(@"%d",percent);
}

messageRecallStatusDidChanged:error:

消息撤回状态发送变化

- (void)messageRecallStatusDidChanged:(BMXMessageObject *)*message* error:(BMXError *)*error*

Discussion

消息撤回状态发送变化

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)messageRecallStatusDidChanged:(BMXMessageObject *)message error:(BMXError *)error {
    MAXLog(@"消息撤回状态");
    
    if (!error) {
        LHMessageModel *deleteObject = nil;
        for (LHMessageModel *recallMessage in self.recallMessages) {
            
            NSString *recallId = [NSString stringWithFormat:@"%lld", recallMessage.messageObjc.msgId];
            NSString *messagId = [NSString stringWithFormat:@"%lld", message.msgId];
            
            if ([recallId isEqualToString:messagId]) {
                deleteObject = recallMessage;
                break;
                
            }
        }
        if(deleteObject) {
            NSInteger index = -1;
            [self.recallMessages removeObject:deleteObject];

messageStatusChanged:error:

消息发送状态发生变化

- (void)messageStatusChanged:(BMXMessageObject *)*message* error:(BMXError *)*error*

Discussion

消息发送状态发生变化

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)messageStatusChanged:(BMXMessageObject *)message error:(BMXError *)error {
    if (error) {
        [HQCustomToast showDialog:error.errorMessage];
    }
    MAXLog(@"message content:%@", message.content);
    if ([self isHaveExtion:message]) {
        //如果是扩展信息(现在的扩展信息,是不展示消息,)所以return不做UI处理
        return;
    } else {
        MAXLogDebug(@"Message have no ext");
        [self.deliveringMsgClientIds removeObject:[NSNumber numberWithLong:(long) message.clientMsgId]];
        for (LHMessageModel *viewmodel in self.dataSource) {
            if ([viewmodel isKindOfClass:[LHMessageModel class]] && viewmodel.messageObjc.clientMsgId  == message.clientMsgId) {
                MAXLogDebug(@"Message found in list");
                NSInteger index = [self.dataSource indexOfObject:viewmodel];
                __block LHChatViewCell *messageCell = (LHChatViewCell *) [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
                if (messageCell == nil) {
                    NSArray *cells = [self.tableView visibleCells];
                    [cells enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * _Nonnull stop) {
                        if ([obj isKindOfClass:[LHChatViewCell class]]) {
- (void)messageStatusChanged:(BMXMessageObject *)message
                       error:(BMXError *)error {

    
    if (!error) {
        UINavigationController *navigation = (UINavigationController *)[self.childViewControllers firstObject];
        if ([NSStringFromClass([navigation.childViewControllers firstObject].class) isEqualToString:@"MainViewController"] ) {
            
            MainViewController *mainVC = [navigation.childViewControllers firstObject];
            [mainVC sendNewMessage:message];
        }
    }
    UINavigationController *navigation = (UINavigationController *)[self.childViewControllers firstObject];
    if ([NSStringFromClass([navigation.childViewControllers firstObject].class) isEqualToString:@"MainViewController"] ) {
        
        MainViewController *mainVC = [navigation.childViewControllers firstObject];
        [mainVC sendNewMessage:message];
    }
     MAXLog(@"消息发送状态发生变化 %u",message.deliverystatus);
}

receiveDeleteMessages:

收到删除消息 (多设备同步删除消息)

- (void)receiveDeleteMessages:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到删除消息 (多设备同步删除消息)

Declared In

  • BMXChatServiceProtocol.h

Example:

receiveReadAllMessages:

收到消息全部已读(多设备同步某消息之前消息全部设置为已读)

- (void)receiveReadAllMessages:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到消息全部已读(多设备同步某消息之前消息全部设置为已读)

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)receiveReadAllMessages:(NSArray<BMXMessageObject *> *)messages {
    UINavigationController *navigation = (UINavigationController *)[self.childViewControllers firstObject];
    if ([NSStringFromClass([navigation.childViewControllers firstObject].class) isEqualToString:@"MainViewController"] ) {
        
        MainViewController *mainVC = [navigation.childViewControllers firstObject];
        [mainVC receiveNewMessage:[messages lastObject]];
    }
    MAXLog(@"已经readall");

}

receiveReadCancelsMessages:

收到消息已读取消(多设备其他设备同步消息已读状态变为未读)

- (void)receiveReadCancelsMessages:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到消息已读取消(多设备其他设备同步消息已读状态变为未读)

Declared In

  • BMXChatServiceProtocol.h

Example:

receivedCommandMessages:

收到命令消息

- (void)receivedCommandMessages:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到命令消息

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)receivedCommandMessages:(NSArray<BMXMessageObject *> *)messages {
    MAXLog(@"收到命令消息 %@", [messages firstObject]);

}

receivedDeliverAcks:

收到消息已送达回执

- (void)receivedDeliverAcks:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到消息已送达回执

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)receivedDeliverAcks:(NSArray<BMXMessageObject*> *)messages {
    MAXLog(@"收到消息已送达回执");
}

receivedMessages:

收到消息

- (void)receivedMessages:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到消息

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)receivedMessages:(NSArray<BMXMessageObject*> *)messages {
    MAXLog(@"11--11---收到");
    if (messages.count > 0) {
        for (BMXMessageObject *message in messages) {
            [self dealWithMessage:message];
        }
    }
}
- (void)receivedMessages:(NSArray<BMXMessageObject*> *)messages {
    UINavigationController *navigation = (UINavigationController *)[self.childViewControllers firstObject];
    if ([NSStringFromClass([navigation.childViewControllers firstObject].class) isEqualToString:@"MainViewController"] ) {
        
        MainViewController *mainVC = [navigation.childViewControllers firstObject];
        
        [mainVC receiveNewMessage:[messages lastObject]];
    }
    MAXLog(@"已经收到消息 %@", [messages firstObject]);
}

receivedReadAcks:

收到消息已读回执

- (void)receivedReadAcks:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到消息已读回执

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)receivedReadAcks:(NSArray<BMXMessageObject*> *)messages {
    //会话列表页面 刷新已读未读状态
    //会话页面 刷新已读未读状态
    
    //更新未读数
    MAXLog(@"收到消息已读回执");
    if (self.messageType == BMXMessageTypeSingle) {
        for (BMXMessageObject *message in messages) {
            for (LHMessageModel *viewmodel in self.dataSource) {
                if ([viewmodel isKindOfClass:[LHMessageModel class]] &&  viewmodel.messageObjc.msgId  == message.msgId) {
                    NSInteger index = [self.dataSource indexOfObject:viewmodel];
                    LHChatViewCell *messageCell = (LHChatViewCell *) [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
                    viewmodel.messageObjc.isReadAcked = YES;
                    messageCell.readStatusLabel.text = NSLocalizedString(@"Read", @"已读");
                }
            }
        }
    } else {
            for (BMXMessageObject *message in messages) {
                for (LHMessageModel *viewmodel in self.dataSource) {
- (void)receivedReadAcks:(NSArray<BMXMessageObject *> *)messages {
    MAXLog(@"收到消息已读回执");
    UINavigationController *navigation = (UINavigationController *)[self.childViewControllers firstObject];
    if ([NSStringFromClass([navigation.childViewControllers firstObject].class) isEqualToString:@"MainViewController"] ) {
        
        MainViewController *mainVC = [navigation.childViewControllers firstObject];
        [mainVC receiveNewMessage:[messages lastObject]];
    }
}

receivedRecallMessages:

收到撤回消息

- (void)receivedRecallMessages:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到撤回消息

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)receivedRecallMessages:(NSArray<BMXMessageObject *> *)messages{
    for (LHMessageModel *lhModel in self.dataSource) {
        if (![lhModel isKindOfClass:[LHMessageModel class]]) {
            continue;
        }
        BMXMessageObject *messageObjec = [messages firstObject];
        if (lhModel.messageObjc.msgId == messageObjec.msgId) {
            
            //更新撤回的信息的显示内容
            lhModel.content = NSLocalizedString(@"Withdrawn_by_the_other_party", @"对方已撤回");
            lhModel.type = MessageBodyType_Text;
            messageObjec.contentType = BMXContentTypeText;
            messageObjec.content = NSLocalizedString(@"Withdrawn_by_the_other_party", @"对方已撤回");
            
            [self.tableView reloadData];
        }
    }
    MAXLog(@"收到撤回的消息");
}
- (void)receivedRecallMessages:(NSArray<BMXMessageObject *> *)messages {
    UINavigationController *navigation = (UINavigationController *)[self.childViewControllers firstObject];
    if ([NSStringFromClass([navigation.childViewControllers firstObject].class) isEqualToString:@"MainViewController"] ) {
        
        MainViewController *mainVC = [navigation.childViewControllers firstObject];
        [mainVC receiveNewMessage:[messages lastObject]];
    }
    MAXLog(@"已经收到消息 %@", [messages firstObject]);
}

receivedSystemMessages:

收到系统通知消息

- (void)receivedSystemMessages:(NSArray<BMXMessageObject*> *)*messages*

Discussion

收到系统通知消息

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)receivedSystemMessages:(NSArray<BMXMessageObject*> *)messages {
    MAXLog(@"收到系统通知消息");
}

retrieveHistoryMessagesConversation:

拉取历史消息

- (void)retrieveHistoryMessagesConversation:(BMXConversation *)*conversation*

Discussion

拉取历史消息

Declared In

  • BMXChatServiceProtocol.h

Example:

- (void)retrieveHistoryMessagesConversation:(BMXConversation *)conversation {
    if (conversation.lastMessage.msgId != 0 ) {
        UINavigationController *navigation = (UINavigationController *)[self.childViewControllers firstObject];
        if ([NSStringFromClass([navigation.childViewControllers firstObject].class) isEqualToString:@"MainViewController"] ) {
            
            MainViewController *mainVC = [navigation.childViewControllers firstObject];
            [mainVC receiveNewMessage:conversation.lastMessage];
        }
    }
}

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

results matching ""

    No results matching ""