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:
- Set the
setRCUltraGroupMessageChangeDelegate:delegate:
[[RCChannelClient sharedChannelManager] setRCUltraGroupMessageChangeDelegate:self];
- Implement the
onUltraGroupMessageModified:message change delegate method. When a remote user modifies a message, this method will be triggered, and thehasChangedproperty in the RCMessage object will be updated toYES:
/*!
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
| Parameter | Type | Description |
|---|---|---|
| messageUId | NSString | The messageUId returned by the server after the message is successfully sent. |
| newContent | RCMessageContent | The new message content. |
| successBlock | Block | Callback for successful message modification. |
| errorBlock | Block | Callback for failed message modification. |
Example Code
RCTextMessage *newTextMessageContent = [RCTextMessage messageWithContent:@"Modified text message content"];
[[RCChannelClient sharedChannelManager] modifyUltraGroupMessage:messageUId
messageContent:textMessage
success:^{ }
error:^(RCErrorCode status) {}];