简体   繁体   English

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

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

I have implemented a chat sample app using Quickblox,And I followed SampleChat app provided by Quckblox(Urls provided below). 我使用Quickblox实现了一个聊天示例应用程序,并且我遵循了Quckblox提供的SampleChat应用程序(下面提供了Urls)。 But I want to update Read and Delivery status of each message. 但我想更新每条消息的读取和传递状态。 How to achieve this? 怎么做到这一点?

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

In link 1 they have explained some code but I'm unable to implement. 在链接1中,他们已经解释了一些代码,但我无法实现。

There are docs for read and delivered status in the link you provided. 您提供的链接中有读取传递状态的文档。

To make this answer more explicit, there are several ways to mark messages as read and delivered. 为了使这个答案更加明确,有几种方法可以将消息标记为已读和已传递。 For delivered marking there is only XMPP way available, use this method from QBChat to do it: 对于交付标记,只有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;

For read marker you can use either REST request using QBRequest method: 对于读取标记,您可以使用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;

or XMPP method of QBChat: 或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;

Anyway look closer to samples and documentation if you need a "live" example. 无论如何,如果您需要一个“实时”示例,请仔细查看示例和文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM