lastMessage
in the conversation will become the last but one message.lastMessage
is used for sorting, the sequence in the conversation list will be affected.orderKey
is used for sorting, the sequence in the conversation list will not be affected.getHistoryMessage
.getHistoryMessage
.// `selectedMsg` is the selected message to be deleted.V2TIMManager.getMessageManager().deleteMessageFromLocalStorage(selectedMsg, new V2TIMCallback() {@Overridepublic void onSuccess() {// Local message deleted successfully}@Overridepublic void onError(int code, String desc) {// Failed to delete the local message}});
// `selectedMsg` is the selected message to be deleted.[[V2TIMManager sharedInstance] deleteMessageFromLocalStorage:selectedMessagesucc:^{NSLog(@"Local message deleted successfully");} fail:^(int code, NSString *msg) {NSLog(@"Failed to delete the local message, code: %d, desc: %@", code, msg);}];
// `selectedMessageList` is the list of selected messages to be deleted.V2TIMManager.getMessageManager().deleteMessages(selectedMessageList, new V2TIMCallback() {@Overridepublic void onSuccess() {// Messages deleted from the cloud successfully}@Overridepublic void onError(int code, String desc) {// Failed to delete the messages from the cloud}});
// `selectedMessageList` is the list of selected messages to be deleted.NSArray *selectedMessageList = @[selectedMessage1, selectedMessage2];[[V2TIMManager sharedInstance] deleteMessages:selectedMessageListsucc:^{NSLog(@"Messages deleted from the cloud successfully");} fail:^(int code, NSString *desc) {NSLog(@"Failed to delete the messages from the cloud, code: %d, desc: %@", code, desc);}];
class Callback final : public V2TIMCallback {public:using SuccessCallback = std::function<void()>;using ErrorCallback = std::function<void(int, const V2TIMString&)>;Callback() = default;~Callback() override = default;void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {success_callback_ = std::move(success_callback);error_callback_ = std::move(error_callback);}void OnSuccess() override {if (success_callback_) {success_callback_();}}void OnError(int error_code, const V2TIMString& error_message) override {if (error_callback_) {error_callback_(error_code, error_message);}}private:SuccessCallback success_callback_;ErrorCallback error_callback_;};// `messageList` is the list of selected messages to be deleted.auto callback = new Callback;callback->SetCallback([=]() {// Messages deleted from the cloud successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to delete the messages from the clouddelete callback;});V2TIMManager::GetInstance()->GetMessageManager()->DeleteMessages(messageList, callback);
Was this page helpful?