I have implemented a chat sample app using Quickblox,And I followed SampleChat app provided by Quckblox(Urls provided below). But I want to update Read and Delivery status of each message. How to achieve this?
In link 1 they have explained some code but I'm unable to implement.
答案 0 :(得分:3)
为了使这个答案更加明确,有几种方法可以将消息标记为已读和已传递。对于交付标记,只有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;
或QBC的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;
如果你需要一个“实时”的例子,无论如何都要更接近样本和文档。