Search code examples
iosobjective-ciphonequickblox

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). 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
  2. 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.


Solution

  • 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:

    /**
     *  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:

    /**
     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:

    /**
     *  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.