please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Unity(Game Solution)/
Message/
SDK
  • Run Demo
  • SDK Integration
  • Initialization
  • Login and Logout
  • Message
    • Message Overview
    • Sending Message
    • Receiving Message
    • Historical Message
    • Forwarding Message
    • Modifying Message
    • Deleting Message
    • Clearing Messages
    • Recalling Message
    • Online Message
    • Read Receipt
    • Querying Message
    • Group @ Message
    • Targeted Group Message
    • Notification Muting
    • Message Extension
  • Conversation
    • Conversation Overview
    • Conversation List
    • Getting Conversation
    • Conversation Unread Count
    • Pinning Conversation to the Top
    • Deleting Conversation
    • Conversation Draft
    • Conversation Mark
    • Conversation Group
  • Group
    • Group Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Group Counter
  • User
    • User Profile
    • User Status
    • Friend Management
    • Friend List
    • Blocklist
  • Changelog
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Deleting Message

Feature Description

Both local messages and cloud messages can be deleted. When cloud messages are deleted, such messages will be deleted both locally and from the cloud and cannot be recovered.
If the last message is deleted, the lastMessage in the conversation will become the last but one message.

Deleting a local message

Call MsgDelete (Details) to delete a local message.
Note:
1. After a historical local message is deleted, the message will be marked as deleted locally by the SDK and can no longer be pulled through MsgGetMsgList.
2. If the application is uninstalled and reinstalled, the deletion marker will be lost locally, and the message can still be pulled through MsgGetMsgList.
Sample code:
public static void MsgDelete()
{
string conv_id = "287646";

MsgDeleteParam message_delete_param = new MsgDeleteParam();
message_delete_param.msg_delete_param_msg = new Message(); // The message to be deleted
message_delete_param.msg_delete_param_is_remble = false; // Delete the local message
TIMResult res = TencentIMSDK.MsgDelete(conv_id, TIMConvType.kTIMConv_C2C, message_delete_param, (int code, string desc, string user_data) => {
// Process the callback logic
});
}

Deleting a message from the cloud

Call MsgDelete (Details) to delete messages from the cloud.
This API deletes messages both locally and from the cloud, which cannot be recovered.
Note:
1. Up to 30 messages can be deleted per call.
2. Messages to be deleted per call must be from the same conversation.
3. This API can be called only once per second.
4. If messages have been pulled on a device by an account, they will remain on the device after the API is called to delete them from the cloud; in other words, deleted messages are not synced.
Sample code:
public static void MsgDelete()
{
string conv_id = "287646";

MsgDeleteParam message_delete_param = new MsgDeleteParam();
message_delete_param.msg_delete_param_msg = new Message(); // The message to be deleted
message_delete_param.msg_delete_param_is_remble = true; // Delete the roaming message
TIMResult res = TencentIMSDK.MsgDelete(conv_id, TIMConvType.kTIMConv_C2C, message_delete_param, (int code, string desc, string user_data) => {
// Process the callback logic
});
}