Delete Messages
Ultra group conversation messages are stored on the server (with free storage for 7 days) and in the user's local database. You can use the IMLib SDK to delete your historical messages, supporting deletion from the local database only, from the RC server only, or from both local and server simultaneously.
- Message deletion operations on the client side refer to removing messages from the current logged-in user's historical message records and do not affect other users' historical message records in the conversation.
- If an App administrator or regular user wants to completely delete a message across the App (e.g., removing a message from all ultra group members' chat histories), they should use the recall message feature on either the client or server side. After successful recall, the original message content will be deleted from all users' local and server historical records.
- Starting from version 5.3.0, it is recommended to use the asynchronous result-returning interfaces in RCChannelClient, while the original synchronous interfaces are deprecated.
| Feature | Local/Server | API |
|---|---|---|
| Delete Messages from All Channels Locally (Timestamp) | Local Only | deleteUltraGroupMessagesForAllChannel |
| Delete Messages from Specified Channel Locally (Timestamp) | Local Only | deleteUltraGroupMessages |
| Delete Messages from Specified Channel on Server (Timestamp) | Server Only | deleteRemoteUltraGroupMessages |
| Delete Messages from Both Local and Remote (Message Objects) | Both Local and Server | deleteRemoteMessages |
Delete Messages from All Channels Locally (Timestamp)
You can delete local historical messages before a specified Unix timestamp (in milliseconds) for all channels in an ultra group conversation. Each operation applies to a single ultra group only; batch deletion across multiple ultra groups is not supported.
The user's historical message records stored on the server remain unaffected. If the user retrieves historical messages from the server, they may still access messages that were deleted locally.
Interface Prototype
- (void)deleteUltraGroupMessagesForAllChannel:(NSString *)targetId
timestamp:(long long)timestamp
completion:(nullable void(^)(BOOL result))completion;
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| targetId | NSString | The targetId of the ultra group conversation. |
| timestamp | long long | Timestamp. Messages before this timestamp will be deleted. Passing 0 deletes all local historical messages for this conversation. |
| completion | Block | Callback for deletion result. |
Example Code
[[RCChannelClient sharedChannelManager]
deleteUltraGroupMessagesForAllChannel:@"targetId"
timestamp:timestamp
completion:^(BOOL){
// Async callback indicating success/failure
}];
Delete Messages from Specified Channel Locally (Timestamp)
You can delete local historical messages before a specified Unix timestamp (in milliseconds) for a specific channel in an ultra group conversation. Each operation applies to a single ultra group only; batch deletion across multiple ultra groups is not supported.
The user's historical message records stored on the server remain unaffected. If the user retrieves historical messages from the server, they may still access messages that were deleted locally.
Interface Prototype
- (void)deleteUltraGroupMessages:(NSString *)targetId
channelId:(nullable NSString *)channelId
timestamp:(long long)timestamp
completion:(nullable void(^)(BOOL result))completion;
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| targetId | NSString | The targetId of the ultra group conversation. |
| channelId | NSString | The channelId of the ultra group channel. |
| timestamp | long long | Timestamp. Messages before this timestamp will be deleted. Passing 0 deletes all local historical messages for this conversation. |
| completion | Block | Callback for deletion result. |
Example Code
[[RCChannelClient sharedChannelManager]
deleteUltraGroupMessages:@"targetId"
channelId:@"channelId"
timestamp:timestamp
completion:^(BOOL){
// Async callback indicating success/failure
}];
Delete Messages from Specified Channel on Server (Timestamp)
You can delete remote historical messages before a specified Unix timestamp (in milliseconds) for a specific channel in an ultra group conversation. Each operation applies to a single ultra group only; batch deletion across multiple ultra groups is not supported.
The user's local historical message records remain unaffected.
After enabling the ultra group service for your App in the RC Console, RC automatically enables historical message storage (free for 7 days).
Interface Prototype
- (void)deleteRemoteUltraGroupMessages:(NSString *)targetId
channelId:(NSString *)channelId
timestamp:(long long)timestamp
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode status))errorBlock
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| targetId | NSString | The targetId of the ultra group conversation. |
| channelId | NSString | The channelId of the ultra group channel. |
| timestamp | long long | Timestamp. Messages before this timestamp will be deleted. Passing 0 deletes all remote historical messages for this conversation. |
| successBlock | Block | Success callback for deletion. |
| errorBlock | Block | Failure callback for deletion. |
Example Code
[[RCChannelClient sharedChannelManager] deleteRemoteUltraGroupMessages:@"targetId" channelId:@"channelId" timestamp:0 success:^{
} error:^(RCErrorCode status) {
}];
Delete Messages from Both Local and Remote for Specified Channel (Message Objects)
If you want to completely remove a set of messages from your ultra group conversation history, use the deleteRemoteMessage: method by passing a list of message objects RCMessage to be deleted.
After successful deletion, the messages will be unavailable from the local database. Retrieving historical messages from the server will also exclude the deleted messages.
Interface Prototype
- (void)deleteRemoteMessage:(RCConversationType)conversationType
targetId:(NSString *)targetId
channelId:(nullable NSString *)channelId
messages:(NSArray<RCMessage *> *)messages
success:(nullable void (^)(void))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock;
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| conversationType | RCConversationType | Conversation type. Use ConversationType_ULTRAGROUP for ultra groups. |
| targetId | NSString | The targetId of the ultra group conversation. |
| channelId | NSString | The channelId of the ultra group channel. |
| messages | NSArray | List of messages to be deleted. Ensure all provided messages belong to the same ultra group channel (channelId). Maximum 100 messages per deletion. |
| successBlock | Block | Success callback for deletion. |
| errorBlock | Block | Failure callback for deletion. |
Sample Code
[[RCChannelClient sharedChannelManager]
deleteRemoteMessage:ConversationType_ULTRAGROUP
targetId:@"targetId"
messages:messages
success:^{}
error:^(RCErrorCode status) {
}];