V2TIMConversation
object information of one or multiple specified conversations.getConversation
(Android / iOS and macOS / Windows) to get the information of a conversation, which is a V2TIMConversation
object. The composition of conversationID
can be referred to the Overview.String conversationID = "conversationID";V2TIMManager.getConversationManager().getConversation(conversationID, new V2TIMValueCallback<V2TIMConversation>() {@Overridepublic void onSuccess(V2TIMConversation v2TIMConversation) {Log.i("imsdk", "success");}@Overridepublic void onError(int code, String desc) {Log.i("imsdk", "failure, code:" + code + ", desc:" + desc);}});
[V2TIMManager.sharedInstance getConversation:@"conversationID" // ID of the conversation to be queriedsucc:^(V2TIMConversation *conv) {// The conversation obtained successfully. The `V2TIMConversation` object was returned.} fail:^(int code, NSString *desc) {// Failed to obtain}];
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_;};V2TIMString conversationID = u8"conversationID";auto callback = new ValueCallback<V2TIMConversation>{};callback->SetCallback([=](const V2TIMConversation& conversation) {// Obtained the conversation successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to obtain the conversationdelete callback;});V2TIMManager::GetInstance()->GetConversationManager()->GetConversation(conversationID, callback);
getConversationList
(Android / iOS and macOS / Windows) to get the list of specified conversations that stores V2TIMConversation
objects.List<String> conversationIDList = new ArrayList<>();conversationIDList.add("conversationID1");conversationIDList.add("conversationID1");V2TIMManager.getConversationManager().getConversationList(conversationIDList, new V2TIMValueCallback<List<V2TIMConversation>>() {@Overridepublic void onSuccess(List<V2TIMConversation> conversationList) {Log.i("imsdk", "success");}@Overridepublic void onError(int code, String desc) {Log.i("imsdk", "failure, code:" + code + ", desc:" + desc);}});
[V2TIMManager.sharedInstance getConversationList:@[@"convID1", @"convID2"] // List of IDs of the conversations to be queriedsucc:^(NSArray<V2TIMConversation *> *list) {// Conversations obtained successfully. The `list` contains `V2TIMConversation` objects.} fail:^(int code, NSString *desc) {// Failed to obtain}];
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"conversationID1");conversationIDList.PushBack(u8"conversationID2");auto callback = new ValueCallback<V2TIMConversationVector>{};callback->SetCallback([=](const V2TIMConversationVector& conversationList) {// Obtained multiple conversations successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to obtain multiple conversationsdelete callback;});V2TIMManager::GetInstance()->GetConversationManager()->GetConversationList(conversationIDList, callback);
Was this page helpful?