Search code examples
iosswiftquickblox

How to retrieve the last message from Quickblox in iOS?


I send message to the chat dialog but I am not able to retreive the last messages.

How to get the the last messages from the chat dialog with a certain ID and and forwards it to the recipient for iOS?


Solution

  • If you have been joined the room, just access lastMessageText directly:

    dialog.lastMessageText
    

    Or get the last message with a certain ID using QBRequest:

    QBRequest.messagesWithDialogID("ID",
        extendedRequest: ["sort_desc" : "date_sent", "limit" : 1],
        forPage: nil,
        successBlock: { (response, messages, page) -> Void in
            println(messages)
        },
        errorBlock: { (response) -> Void in
            println(response)
        }
    )