V2TIM_CONVERSATION_MARK_TYPE_UNREAD
, the unread count at the underlying layer will not change.Attribute | Definition | Description |
conversationIDList | List of conversation IDs | Up to 100 conversations can be marked at a time. |
markType | Mark type | A conversation can be marked as a favorite, unread, collapsed, or hidden. |
enableMark | Mark/Unmark | A conversation can be marked/unmarked. |
32 ≤ n < 64
indicates that n
must be equal to or greater than 32 and less than 64). For example, 0x1LL << 32
indicates "Online on an iPhone".List<String> conversationIDList = new ArrayList<>();conversationIDList.add("c2c_user1");// Mark typelong markType = V2TIMConversation.V2TIM_CONVERSATION_MARK_TYPE_STAR;// Extended mark type// long markType = 0x1L << 32;V2TIMManager.getConversationManager().markConversation(conversationIDList, markType, true, new V2TIMValueCallback<List<V2TIMConversationOperationResult>>() {@Overridepublic void onSuccess(List<V2TIMConversationOperationResult> v2TIMConversationOperationResults) {// Marked the conversation successfully}@Overridepublic void onError(int code, String desc) {// Failed to mark the conversation}});
// Mark typeNSNumber *markType = @(V2TIM_CONVERSATION_MARK_TYPE_STAR);// Extended mark type// NSNumber *markType = @(0x1LL << 32);// Mark a conversationBOOL enableMark = YES;// Unmark a conversation// BOOL enableMark = NO;[[V2TIMManager sharedInstance] markConversation:@[@"c2c_yahaha"] markType:markType enableMark:enableMark succ:^(NSArray<V2TIMConversationOperationResult *> *result){// Marked the conversation successfully} fail:^(int code, NSString *desc) {// Failed to mark the conversation}];
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");// Mark typeuint64_t markType = V2TIMConversationMarkType::V2TIM_CONVERSATION_MARK_TYPE_STAR;// Extended mark typeuint64_t markType = static_cast<uint64_t>(0x1) << 32;auto callback = new ValueCallback<V2TIMConversationOperationResultVector>{};callback->SetCallback([=](const V2TIMConversationOperationResultVector& conversationOperationResultList) {// Marked the conversation successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to mark the conversationdelete callback;});V2TIMManager::GetInstance()->GetConversationManager()->MarkConversation(conversationIDList, markType, true,callback);
markList
field (Android / iOS and macOS / Windows) in V2TIMConversation
of the conversation will change. You can call the addConversationListener
API (Android / iOS and macOS / Windows) to listen for such a change notification.V2TIMConversationListener listener = new V2TIMConversationListener() {@Overridepublic void onConversationChanged(List<V2TIMConversation> conversationList) {for (V2TIMConversation conversation : conversationList) {// Get the new mark information of the conversationList<Long> markList = conversation.getMarkList();}}};V2TIMManager.getConversationManager().addConversationListener(listener);
// Delete the conversation group[[V2TIMManager sharedInstance] addConversationListener:self];- (void)onConversationChanged:(NSArray<V2TIMConversation*> *) conversationList{for (V2TIMConversation *conv in conversationList) {// Get the new mark information of the conversationNSArray *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];// Get the new mark information of the conversationconst UInt64Vector& markList = conversation.markList;}}// Other members …};// Add a conversation event listener. Keep `conversationListener` valid before the listener is removed to ensure event callbacks are received.ConversationListener conversationListener;V2TIMManager::GetInstance()->GetConversationManager()->AddConversationListener(&conversationListener);
getConversationListByFilter
API (Android / iOS and macOS / Windows) to pull a specified marked conversation.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) {// Conversation list obtained successfully}@Overridepublic void onError(int code, String desc) {// Failed to obtain the conversation list}});
// Pull a specified marked conversationV2TIMConversationListFilter *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) {// Obtained the conversation list successfully. `list` is the conversation list.} fail:^(int code, NSString *desc) {// Failed to obtain the conversation list}];
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) {// Conversation list obtained successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to obtain the conversation listdelete callback;});V2TIMManager::GetInstance()->GetConversationManager()->GetConversationListByFilter(filter, callback);
Was this page helpful?