# 编辑和删除消息

> Edit and delete messages in channels.

Vivox 提供了编辑和删除已发送到频道的消息的方法。

## 编辑频道消息

Vivox 允许用户使用 [`VivoxService.Instance.EditChannelTextMessageAsync(string channelName, string messageId, string newMessage)`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_EditChannelTextMessageAsync_System_String_System_String_System_String_) 编辑他们发送到频道的消息文本，其中 channelName 是消息发送到的频道的名称，messageId 是要更改的消息的 ID，newMessage 是更新的消息文本。

当频道中的任何人成功编辑消息后，频道中的所有人都将收到一个 [`VivoxService.Instance.ChannelMessageEdited`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_ChannelMessageEdited) 操作，其中包含已编辑的 VivoxMessage 以及更新的 MessageText。

```cs
public async void UpdateChannelMessageAsync(VivoxMessage messageToUpdate, string updatedMessageText)
{
    await VivoxService.Instance.EditChannelTextMessageAsync(messageToUpdate.ChannelName, messageToUpdate.MessageId, updatedMessageText);
}
```

## 删除频道消息

Vivox 允许用户使用 [`VivoxService.Instance.DeleteChannelTextMessageAsync(string channelName, string messageId)`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_DeleteChannelTextMessageAsync_System_String_System_String_) 删除他们发送到频道的消息，其中 channelName 是消息发送到的频道的名称，messageId 是要删除的消息的 ID。

当频道中的任何人成功删除消息后，频道中的所有人都将收到一个 [`VivoxService.Instance.ChannelMessageDeleted`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_ChannelMessageDeleted) 操作，其中包含已删除的 VivoxMessage。

```cs
public async void DeleteChannelMessageAsync(VivoxMessage messageToDelete)
{
    await VivoxService.Instance.DeleteChannelTextMessageAsync(messageToDelete.ChannelName, messageToDelete.MessageId)
}
```
