【问题标题】:How to integrate mark message feature for read messages in Quickblox如何在 Quickblox 中为已读消息集成标记消息功能
【发布时间】:2019-07-11 11:10:50
【问题描述】:

我正在使用 ChatviewcontrollerQuickblox 来显示聊天详细信息。如果消息已读,我想将消息标记为已读。

我看到 QMChatService.m 类中有一个可用的方法

- (void)chatDidReadMessageWithID:(NSString *)messageID
                    dialogID:(NSString *)dialogID
                    readerID:(NSUInteger)readerID{

------------
if ([self.multicastDelegate respondsToSelector:@selector(chatService:didUpdateMessage:forDialogID:)]) {
            [self.multicastDelegate chatService:self didUpdateMessage:message forDialogID:dialogID];
        }
}

在这里我看到chatService:didUpdateMessage: 一个方法调用了另一个场景,因此无法识别如何标记消息。

【问题讨论】:

    标签: objective-c quickblox


    【解决方案1】:

    我已经这样解决了 QBChatMessage 具有三个属性 readIDs(阅读消息的用户数组)、deliveredIDs(消息传递给的用户数组)、receiverID。

    以下是 ChatViewController.m 中的完整代码

    -(void)collectionView:(QMChatCollectionView *)collectionView configureCell:(UICollectionViewCell *)cell forIndexPath:(NSIndexPath *)indexPath {

    QBChatMessage *message = [self.chatDataSource messageForIndexPath:indexPath];

    if (message.senderID == [QBSession currentSession].currentUser.ID){
    
        NSString *imageName = @"sent.png";
        if((self.dialog.type == QBChatDialogTypePrivate) && [message.readIDs containsObject:@(message.recipientID)]) {
            imageName = @"read.png";
        }
        else if((self.dialog.type == QBChatDialogTypePrivate) && [message.deliveredIDs containsObject:@(message.recipientID)]) {
            imageName = @"received.png";
        }
        [chatCell markImageView].image = [UIImage imageNamed:imageName];
    }
    

    }

    这里 markImageView 是单元格的 UIImagview 属性。

    【讨论】:

      猜你喜欢
      • 2015-03-26
      • 2020-10-16
      • 1970-01-01
      • 2021-09-05
      • 1970-01-01
      • 2019-03-14
      • 1970-01-01
      • 1970-01-01
      • 2017-10-03
      相关资源
      最近更新 更多