Modify Messages
After successfully sending an ultra group message, you can actively modify the content of the sent message.
Listen for Message Modifications by Remote Users
You can set up the setUltraGroupMessageChangeListener listener to monitor message modification operations by remote users. The application will receive notifications through the onUltraGroupMessageModified method. After a message is modified, Message#isHasChanged() will return true.
//Ultra group message change notifications
interface UltraGroupMessageChangeListener {
//Message expansion updates or deletions
void onUltraGroupMessageExpansionUpdated(List<Message> messages);
//Message content changes
void onUltraGroupMessageModified(List<Message> messages);
//Message recalls
void onUltraGroupMessageRecalled(List<Message> messages);
}
//Set ultra group message change listener
public void setUltraGroupMessageChangeListener(IRongCoreListener.UltraGroupMessageChangeListener listener)
Modify Sent Message Content for Local Users
After a local user successfully sends a message, the server returns the message's UID. To modify the message content, use modifyUltraGroupMessage by passing the Message UID of the message to be modified and the new message content. After modification, Message#isHasChanged() will return true.
tip
- The message type cannot be modified. If the original message is a text message, the new message content must be of type
TextMessage. - You cannot modify messages sent by others.
Sample Code
TextMessage newContent = TextMessage.obtain("Modified text message content");
ChannelClient.getInstance().modifyUltraGroupMessage(msgUid, newContent,
new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() { }
@Override
public void onError(IRongCoreEnum.CoreErrorCode ErrorCode) { }
});