String conversationID = "conversationID";V2TIMManager.getConversationManager().deleteConversation(conversationID, new V2TIMCallback() {@Overridepublic void onSuccess() {// 删除会话成功}@Overridepublic void onError(int code, String desc) {// 删除会话失败}});
NSString *conversationID = @"conversationID";[[V2TIMManager sharedInstance] deleteConversation:conversationIDsucc:^{// 删除会话成功}fail:^(int code, NSString *desc) {// 删除会话失败}];
class Callback final : public V2TIMCallback {public:using SuccessCallback = std::function<void()>;using ErrorCallback = std::function<void(int, const V2TIMString&)>;Callback() = default;~Callback() override = default;void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {success_callback_ = std::move(success_callback);error_callback_ = std::move(error_callback);}void OnSuccess() override {if (success_callback_) {success_callback_();}}void OnError(int error_code, const V2TIMString& error_message) override {if (error_callback_) {error_callback_(error_code, error_message);}}private:SuccessCallback success_callback_;ErrorCallback error_callback_;};V2TIMString groupName = u8"conversationID";auto callback = new Callback;callback->SetCallback([=]() {// 删除会话成功delete callback;},[=](int error_code, const V2TIMString& error_message) {// 删除会话失败delete callback;});V2TIMManager::GetInstance()->GetConversationManager()->DeleteConversationGroup(groupName, callback);
deleteConversationList
(Android / iOS & Mac / Windows) 接口,删除指定的会话。clearMessage 设置为 false 时,会保留会话消息;设置为 true 时,本地和服务器的消息会一起删除,并且不可恢复。List<String> conversationIDList = new ArrayList<>();conversationIDList.add("c2c_userID");conversationIDList.add("group_groupID");V2TIMManager.getConversationManager().deleteConversationList(conversationIDList, true, new V2TIMValueCallback<List<V2TIMConversationOperationResult>>() {@Overridepublic void onSuccess(List<V2TIMConversationOperationResult> results) {// 删除会话成功for (V2TIMConversationOperationResult result : results) {int code = result.getResultCode();String info = result.getResultInfo();String conversationID = result.getConversationID();}}@Overridepublic void onError(int code, String desc) {// 删除会话失败}});
NSMutableArray *conversationIDList = [NSMutableArray array];[conversationIDList addObject:@"c2c_userID"];[conversationIDList addObject:@"group_groupID"];[[V2TIMManager sharedInstance] deleteConversationList:conversationIDListclearMessage:truesucc:^(NSArray<V2TIMConversationOperationResult *> *results) {// 删除会话成功for (V2TIMConversationOperationResult *result in results) {int code = result.resultCode;NSString *info = result.resultInfo;NSString *conversationID = result.conversationID;}}fail:^(int code, NSString *desc) {// 删除会话失败}];
template <class T>class ValueCallback final : public V2TIMValueCallback<T> {public:using SuccessCallback = std::function<void(const T&)>;using ErrorCallback = std::function<void(int, const V2TIMString&)>;ValueCallback() = default;~ValueCallback() override = default;void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {success_callback_ = std::move(success_callback);error_callback_ = std::move(error_callback);}void OnSuccess(const T& value) override {if (success_callback_) {success_callback_(value);}}void OnError(int error_code, const V2TIMString& error_message) override {if (error_callback_) {error_callback_(error_code, error_message);}}private:SuccessCallback success_callback_;ErrorCallback error_callback_;};V2TIMStringVector conversationIDList;conversationIDList.PushBack(u8"c2c_userID");conversationIDList.PushBack(u8"group_groupID");auto callback = new ValueCallback<V2TIMConversationOperationResultVector>{};callback->SetCallback([=](const V2TIMConversationOperationResultVector& results) {// 删除会话成功for (size_t i = 0; i < results.Size(); ++i) {const V2TIMConversationOperationResult& result = results[i];int code = result.resultCode;V2TIMString info = result.resultInfo;V2TIMString conversationID = result.conversationID;}delete callback;},[=](int error_code, const V2TIMString& error_message) {// 删除会话失败delete callback;});V2TIMManager::GetInstance()->GetConversationManager()->DeleteConversationList(conversationIDList, true, callback);
addConversationListener
(Android / iOS & Mac / Windows) 添加会话监听器,就可以在 onConversationDeleted
中获取会话被删除的通知。@Overridepublic void onConversationDeleted(List<String> conversationIDList) {Log.i("imsdk", "onConversationDeleted");}
- (void)onConversationDeleted:(NSArray<NSString *> *)conversationIDList {// 会话被删除}
void OnConversationDeleted(const V2TIMStringVector &conversationIDList) override {// 收到会话被删除通知}
本页内容是否解决了您的问题?