Skip to main content

Modify Messages

After successfully sending an ultra group message, you can actively modify the content of the sent message.

Listening for Message Changes by Remote Users

You can monitor message modification operations performed by remote users by setting the setRCUltraGroupMessageChangeDelegate delegate:

  1. Set the setRCUltraGroupMessageChangeDelegate: delegate:
[[RCChannelClient sharedChannelManager] setRCUltraGroupMessageChangeDelegate:self];
  1. Implement the onUltraGroupMessageModified: message change delegate method. When a remote user modifies a message, this method will be triggered, and the hasChanged property in the RCMessage object will be updated to YES:
/*!
Message content changed

@param messages Message collection
*/
- (void)onUltraGroupMessageModified:(NSArray<RCMessage*>*)messages {

}

Modifying Sent Messages by Local Users

After a local user successfully sends a message, the server returns the message's messageUId. To modify the message content, use the modifyUltraGroupMessage method, passing in the messageUId of the message to be modified and the new message content. After the message is modified, the hasChanged property of the RCMessage object will be updated to YES.

tip
  • The message type cannot be modified. If the original message is a text message, the new message content must be of type RCTextMessage.
  • You cannot modify messages sent by others.

Interface Prototype

- (void)modifyUltraGroupMessage:(NSString *)messageUId
messageContent:(RCMessageContent *)newContent
success:(nullable void (^)(void))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock;

Parameter Description

ParameterTypeDescription
messageUIdNSStringThe messageUId returned by the server after the message is successfully sent.
newContentRCMessageContentThe new message content.
successBlockBlockCallback for successful message modification.
errorBlockBlockCallback for failed message modification.

Example Code

RCTextMessage *newTextMessageContent = [RCTextMessage messageWithContent:@"Modified text message content"];

[[RCChannelClient sharedChannelManager] modifyUltraGroupMessage:messageUId
messageContent:textMessage
success:^{ }
error:^(RCErrorCode status) {}];