V2TIM_CONVERSATION_MARK_TYPE_UNREAD
,会话的底层的未读数并不会发生改变。属性 | 含义 | 说明 |
conversationIDList | 会话 ID 列表 | 一次标记最大支持 100 个会话 |
markType | 标记类型 | 会话标星、会话标记未读、会话折叠、会话隐藏等 |
enableMark | 标记/取消标记 | 标记或取消标记 |
List<String> conversationIDList = new ArrayList<>();conversationIDList.add("c2c_user1");// 标记类型long markType = V2TIMConversation.V2TIM_CONVERSATION_MARK_TYPE_STAR;// 扩展标记类型// long markType = 0x1L << 32;V2TIMManager.getConversationManager().markConversation(conversationIDList, markType, true, new V2TIMValueCallback<List<V2TIMConversationOperationResult>>() {@Overridepublic void onSuccess(List<V2TIMConversationOperationResult> v2TIMConversationOperationResults) {// 标记会话成功}@Overridepublic void onError(int code, String desc) {// 标记会话失败}});
// 标记类型NSNumber *markType = @(V2TIM_CONVERSATION_MARK_TYPE_STAR);// 扩展标记类型// NSNumber *markType = @(0x1LL << 32);// 标记会话BOOL enableMark = YES;// 取消标记会话// BOOL enableMark = NO;[[V2TIMManager sharedInstance] markConversation:@[@"c2c_yahaha"] markType:markType enableMark:enableMark succ:^(NSArray<V2TIMConversationOperationResult *> *result){// 标记会话成功} 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_user1");// 标记类型uint64_t markType = V2TIMConversationMarkType::V2TIM_CONVERSATION_MARK_TYPE_STAR;// 扩展标记类型uint64_t markType = static_cast<uint64_t>(0x1) << 32;auto callback = new ValueCallback<V2TIMConversationOperationResultVector>{};callback->SetCallback([=](const V2TIMConversationOperationResultVector& conversationOperationResultList) {// 标记会话成功delete callback;},[=](int error_code, const V2TIMString& error_message) {// 标记会话失败delete callback;});V2TIMManager::GetInstance()->GetConversationManager()->MarkConversation(conversationIDList, markType, true,callback);
V2TIMConversation
的 markList
(Android / iOS & Mac / Windows) 字段会发生变更,您可以调用 addConversationListener
(Android / iOS & Mac / Windows) 接口监听会话变更通知。V2TIMConversationListener listener = new V2TIMConversationListener() {@Overridepublic void onConversationChanged(List<V2TIMConversation> conversationList) {for (V2TIMConversation conversation : conversationList) {// 获取会话新的标记信息List<Long> markList = conversation.getMarkList();}}};V2TIMManager.getConversationManager().addConversationListener(listener);
// 删除会话分组[[V2TIMManager sharedInstance] addConversationListener:self];- (void)onConversationChanged:(NSArray<V2TIMConversation*> *) conversationList{for (V2TIMConversation *conv in conversationList) {// 获取会话新的标记信息NSArray *mark_list = conv.markList;}}
class ConversationListener final : public V2TIMConversationListener {public:void OnConversationChanged(const V2TIMConversationVector& conversationList) override {for (size_t i = 0; i < conversationList.Size(); ++i) {const V2TIMConversation& conversation = conversationList[i];// 获取会话新的标记信息const UInt64Vector& markList = conversation.markList;}}// 其他成员 ...};// 添加会话事件监听器,注意在移除监听器之前需要保持 conversationListener 的生命期,以免接收不到事件回调ConversationListener conversationListener;V2TIMManager::GetInstance()->GetConversationManager()->AddConversationListener(&conversationListener);
V2TIMConversationListFilter filter = new V2TIMConversationListFilter();filter.setMarkType(V2TIMConversation.V2TIM_CONVERSATION_MARK_TYPE_STAR);filter.setCount(50);filter.setNextSeq(0);V2TIMManager.getConversationManager().getConversationListByFilter(filter, new V2TIMValueCallback<V2TIMConversationResult>() {@Overridepublic void onSuccess(V2TIMConversationResult v2TIMConversationResult) {// 获取会话列表成功}@Overridepublic void onError(int code, String desc) {// 获取会话列表失败}});
// 拉取指定标记会话V2TIMConversationListFilter *filter = [[V2TIMConversationListFilter alloc] init];filter.markType = V2TIM_CONVERSATION_MARK_TYPE_STAR;filter.count = 50;filter.nextSeq = 0;[[V2TIMManager sharedInstance] getConversationListByFilter:filter succ:^(NSArray<V2TIMConversation *> *list, uint64_t nextSeq, BOOL isFinished) {// 获取会话列表成功,list 为会话列表} 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_;};V2TIMConversationListFilter filter;filter.nextSeq = 0;filter.count = 50;filter.markType = V2TIMConversationMarkType::V2TIM_CONVERSATION_MARK_TYPE_STAR;auto callback = new ValueCallback<V2TIMConversationResult>{};callback->SetCallback([=](const V2TIMConversationResult& conversationResult) {// 获取会话列表成功delete callback;},[=](int error_code, const V2TIMString& error_message) {// 获取会话列表失败delete callback;});V2TIMManager::GetInstance()->GetConversationManager()->GetConversationListByFilter(filter, callback);
本页内容是否解决了您的问题?