Chat SDKs iOS v4
Chat SDKs iOS
Chat SDKs
iOS
Version 4
A user can update any of their own text and file messages sent using UserMessageUpdateParams
and FileMessageUpdateParams
. An error is returned if a user attempts to update another user's messages. In addition, channel operators can update any messages sent in the channel.
var params = UserMessageUpdateParams(message: NEW_TEXT_MESSAGE)
params.customType = NEW_CUSTOM_TYPE
params.data = NEW_DATA
// The USER_MESSAGE_ID argument below indicates the unique message ID
// of a UserMessage object to update.
channel.updateUserMessage(messageId: USER_MESSAGE_ID, params: params) { (userMessage, error) in
guard error == nil else {
// Handle error.
return
}
// The message is successfully updated.
// Through the userMessage parameter of the callback method,
// you could check if the update operation has been performed right.
}
let params = FileMessageUpdateParams()
params.data = NEW_DATA
params.customType = NEW_CUSTOM_TYPE
// The FILE_MESSAGE_ID argument below indicates the unique message ID of a FileMessage object to update.
channel.updateFileMessage(messageId: FILE_MESSAGE_ID, params: params) { (fileMessage, error) in
guard error == nil else {
// Handle error.
return
}
// The message is successfully updated.
// Through the fileMessage parameter of the callback method,
// you could check if the update operation has been performed right.
}
If a message is updated, the channel(_:didUpdate:)
method in channel delegate will be invoked on all users' devices except the one that updated the message.
class CustomViewController: UIViewController, OpenChannelDelegate {
func initViewController() {
SendbirdChat.add(self, identifier: self.delegateIdentifier)
}
func channel(_ channel: BaseChannel, didUpdate message: BaseMessage) {
}
}
class CustomViewController: UIViewController, GroupChannelDelegate {
func initViewController() {
SendbirdChat.add(self, identifier: self.delegateIdentifier)
}
func channel(_ channel: BaseChannel, didUpdate message: BaseMessage) {
}
}