- Android
- iOS
- JavaScript
- Flutter
- ReactNative
- HarmonyOS
Remove the current user's message history locally and in the cloud. The removal is synchronized to the user's other devices. A successful call does not affect whether the other participant or other group members can continue viewing the messages. Batch removal of multiple messages in the same conversation is supported.
Parameters
| Name | Type | Description | Version |
|---|---|---|---|
| conversation | Conversation | Conversation identifier | 1.0.0 |
| clientMsgNoList | List[] | List of locally unique message numbers | 1.0.0 |
| callback | IMessageManager.ISimpleCallback | Result callback | 1.0.0 |
Code Example
Conversation conversation = new Conversation(Conversation.ConversationType.GROUP, "groupId1");
List<Long> clientMsgNoList = new ArrayList<>();
clientMsgNoList.add(111L);
clientMsgNoList.add(222L);
clientMsgNoList.add(333L);
JIM.getInstance().getMessageManager().deleteMessagesByClientMsgNoList(conversation, clientMsgNoList, new IMessageManager.ISimpleCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(int errorCode) {
}
});
Remove the current user's message history locally and in the cloud. The removal is synchronized to the user's other devices. A successful call does not affect whether the other participant or other group members can continue viewing the messages. Batch removal of multiple messages in the same conversation is supported.
Parameters
| Name | Type | Description | Version |
|---|---|---|---|
| conversation | JConversation | Conversation identifier | 1.0.0 |
| clientMsgNoList | NSArray <NSNumber *> | List of locally unique message numbers | 1.0.0 |
| successBlock | Success callback | 1.0.0 | |
| errorBlock | Failure callback | 1.0.0 |
Code Example
JConversation *conversation = [[JConversation alloc] initWithConversationType:JConversationTypeGroup conversationId:@"groupId1"];
NSArray <NSNumber *> *clientMsgNoList = @[@(111), @(222), @(333)];
[JIM.shared.messageManager deleteMessagesByClientMsgNoList:clientMsgNoList
conversation:conversation
success:^{
} error:^(JErrorCode errorCode) {
}];
Remove the current user's message history locally and in the cloud. The removal is synchronized to the user's other devices and does not affect whether the other participant or other group members can continue viewing the messages. Batch removal of multiple messages in the same conversation is supported. The _messages_ parameter is a message array; each message is described below:
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| message | Object | Yes | - | Clear message history | 1.0.0 |
| message.conversationType | Number | Yes | - | Conversation type | 1.0.0 |
| message.conversationId | String | Yes | - | Conversation ID. For PRIVATE conversations, it is the recipient userId; for GROUP conversations, it is the group ID. | 1.0.0 |
| message.messageIndex | Number | Yes | - | Message index. Available from Message. | 1.0.0 |
| message.sentTime | Number | Yes | - | Message send time. Available from Message. | 1.0.0 |
| message.tid | String | Yes | - | Message ID. Available from Message. | 1.0.0 |
| message.messageId | String | Yes | - | Unique message ID. Available from Message. | 1.0.0 |
Success Callback
No parameters are returned. The callback indicates success when invoked.
Failure Callback
| Name | Type | Description | Version |
|---|---|---|---|
| error | Object | A status code is provided when sending fails. Check error.msg directly or see status codes. | 1.0.0 |
Code Example
let { ConversationType } = JIM;
// This example uses mock data. Retrieve actual data from the message-history API.
let messages = [
{
conversationType: ConversationType.PRIVATE,
conversationId: 'userid1',
messageIndex: 128,
sentTime: 1714235241490,
messageId: 'nreayt7ha4ggqlcv',
tid: 'nreayt7ha4ggqlcv',
},
//...
];
jim.removeMessages(messages).then(() => {
console.log('remove messages successfully.')
});
Remove the current user's message history locally and in the cloud. The removal is synchronized to the user's other devices. A successful call does not affect whether the other participant or other group members can continue viewing the messages. Batch removal of multiple messages in the same conversation is supported.
Parameters
| Name | Type | Description | Version |
|---|---|---|---|
| conver | Conversation | Conversation identifier | 1.0.0 |
| msgIds | string[] | List of locally unique message numbers | 1.0.0 |
| delScope | number | 0: remove only for the current user; 1: remove for both sides, so other users in the conversation cannot see the messages. | 1.0.0 |
| callback | CommonCallback | Result callback | 1.0.0 |
Code Example
let conver = new Conversation("userid1",1)
JuggleIm.instance.getMessageManager().delMessages(conver,["message_id1","message_id2"],1,(code)=>{})
Parameters
| Name | Type | Required | Default | Description | Version |
|---|---|---|---|---|---|
| conversation | Conversation | Yes | Conversation object. When the conversation type is private, the conversation ID is the other user's userId; when it is group, it is the group ID. | 0.6.3 | |
| startTime | int | Yes | Timestamp. Messages earlier than this time are deleted. 0 indicates the default current time. | 0.6.3 | |
| forAllUsers | bool | No | false | Message removal scope. true removes message history for all users; false removes it only for the current user. | 0.6.3 |
forAllUsers Use Cases
Group scenario: control deletion actions by permission. For example, administrators can remove message history for all members, while regular members can remove only their own message history.
Private-chat scenario: typically offers removal of only the current user's and the other participant's message history.
Code Example
Conversation conversation = Conversation(2, 'groupId1');
List<int> clientMsgNoList = [1000, 10001];
bool forAllUsers = false;
await JuggleIm.instance.deleteMessagesByClientMsgNoList(conversation, clientMsgNoList, forAllUsers);