如何使用 Quickblox IOS 更新已发送和已接收消息的阅读和传递状态?

How to update Read and Delivery status of sent and received messages using Quickblox IOS?

我已经使用 Quickblox 实现了一个聊天示例应用程序,并且我遵循了 Quckblox 提供的 SampleChat 应用程序(下面提供了网址)。但我想更新每条消息的阅读和传递状态。如何实现?

  1. http://quickblox.com/developers/SimpleSample-chat_users-ios
  2. https://github.com/QuickBlox/quickblox-ios-sdk/tree/master/sample-chat

在 link1 中,他们解释了一些代码,但我无法实现。

您提供的 link 中有 read and delivered 状态的文档。

为了使这个答案更明确,有几种方法可以将邮件标记为已读和已送达。对于交付标记,只有 XMPP 方式可用,请使用 QBChat 中的此方法来执行此操作:

/**
 *  Send "delivered" status for message.
 *
 *  @param message      QBChatMessage message to mark as delivered.
 *  @param completion   Completion block with failure error.
 */
- (void)markAsDelivered:(QB_NONNULL QBChatMessage *)message completion:(QB_NULLABLE QBChatCompletionBlock)completion;

对于读取标记,您可以通过 QBRequest 方法使用任一 REST 请求:

/**
 Mark messages as read.

 @note Updates message "read" status only on server.

 @param dialogID dialog ID.
 @param messagesIDs Set of chat message IDs to mark as read. If messageIDs is nil then all messages in dialog will be marked as read.
 @param successBlock Block with response instance if request succeded.
 @param errorBlock Block with response instance if request failed.
 @return An instance, which conforms Cancelable protocol. Use this instance to cancel the operation.
 */
+ (QB_NONNULL QBRequest *)markMessagesAsRead:(QB_NONNULL NSSet QB_GENERIC(NSString *) *)messagesIDs
                                    dialogID:(QB_NONNULL NSString *)dialogID
                                successBlock:(QB_NULLABLE void(^)(QBResponse * QB_NONNULL_S response))successBlock
                                  errorBlock:(QB_NULLABLE QBRequestErrorBlock)errorBlock;

或QBChat的XMPP方法:

/**
 *  Send "read" status for message and update "read" status on a server
 *
 *  @param message      QBChatMessage message to mark as read.
 *  @param completion   Completion block with failure error.
 */
- (void)readMessage:(QB_NONNULL QBChatMessage *)message completion:(QB_NULLABLE QBChatCompletionBlock)completion;

无论如何,如果您需要 "live" 示例,请仔细查看示例和文档。