V2TIMGroupInfo
object, which is created and returned by the IM SDK and cannot be customized.getGroupsInfo
(Android / iOS and macOS / Windows) to get the group profile. This API supports passing in multiple groupID
values at a time to batch get group profiles.V2TIMManager.getGroupManager().getGroupsInfo(groupIDList, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {@Overridepublic void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {// Obtained the group profile successfully}@Overridepublic void onError(int code, String desc) {// Failed to obtain the group profile}});
[[V2TIMManager sharedInstance] getGroupsInfo:@[@"groupA"] succ:^(NSArray<V2TIMGroupInfoResult *> *groupResultList) {// Obtained the group profile successfully} fail:^(int code, NSString *desc) {// Failed to obtain the group profile}];
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 groupIDList;groupIDList.PushBack("group1");auto callback = new ValueCallback<V2TIMGroupInfoResultVector>{};callback->SetCallback([=](const V2TIMGroupInfoResultVector& groupInfoResultList) {// Obtained the group profile successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to obtain the group profiledelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->GetGroupsInfo(groupIDList, callback);
addGroupListener
to add a group event listener, after the group profile is modified, all the group members will receive the onGroupInfoChanged
callback (Android / iOS and macOS / Windows).Group Type | Member Roles Allowed to Modify the Group Profile |
Work group (Work) | All group members |
Public group (Public) | Group owner and admin |
Meeting group (Meeting) | Group owner and admin |
Community (Community) | Group owner and admin |
Audio-video group (AVChatRoom) | Group owner |
V2TIMGroupInfo
can be modified, but only those writable.// Sample code: Modify group profileV2TIMGroupInfo v2TIMGroupInfo = new V2TIMGroupInfo();v2TIMGroupInfo.setGroupID("Group ID of the group to be modified");v2TIMGroupInfo.setFaceUrl("http://xxxx");V2TIMManager.getGroupManager().setGroupInfo(v2TIMGroupInfo, new V2TIMCallback() {@Overridepublic void onSuccess() {// Modified the group profile successfully}@Overridepublic void onError(int code, String desc) {// Failed to modify the group profile}});
V2TIMGroupInfo *info = [[V2TIMGroupInfo alloc] init];info.groupID = @"Group ID of the group to be modified";info.faceURL = @"http://xxxx";[[V2TIMManager sharedInstance] setGroupInfo:info succ:^{// Modified the group profile successfully} fail:^(int code, NSString *desc) {// Failed to modify the group profile}];
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_;};V2TIMGroupInfo info;info.groupID = "Group ID to be modified";info.faceURL = "http://xxxx";info.modifyFlag |= V2TIM_GROUP_INFO_MODIFY_FLAG_FACE_URL;auto callback = new Callback;callback->SetCallback([=]() {// Modified the group profile successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to modify the group profiledelete callback;});V2TIMManager::GetInstance()->GetGroupManager()->SetGroupInfo(info, callback);
customInfo
attribute in the V2TIMGroupInfo
group profile is the custom group field, which can be modified by calling the setGroupInfo
API mentioned in the previous section.V2TIMGroupInfo
, setting the custom group field involves two steps:setGroupInfo
API to set the field with up to 512 bytes.initGroupAttributes
API to set the group attribute. This allows for greater flexibility (requiring no configuration in the console) and storage (up to 16 KB). For more information, see Custom Group Attribute.setGroupReceiveMessageOpt
API (Android / iOS and macOS / Windows) to change the group message receiving option. This setting will take effect only for the group member and will not affect the setting of other group members.V2TIMReceiveMessageOpt
has the following options:Message Receiving Option | Supported Type | Description |
V2TIM_RECEIVE_MESSAGE | One-to-one Chat, Group Chat, All Messages | Receive messages normally when online, and receive offline push notifications when offline |
V2TIM_NOT_RECEIVE_MESSAGE | One-to-one Chat, Group Chat | Do not receive messages whether online or offline |
V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE | One-to-one Chat, Group Chat, All Messages | Receive messages normally when online, but do not receive offline push notifications when offline |
V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT | Group Chat | Receive messages online, only receive at message pushes when offline |
V2TIM_NOT_RECEIVE_MESSAGE_EXCEPT_AT | Topic | Only receive at messages when online or offline |
V2TIMReceiveMessageOpt
options can implement different Do Not Disturb effects:Do Not Disturb Effect | Message Receiving Option | Description |
Do not receive any messages at all | V2TIM_NOT_RECEIVE_MESSAGE | No messages can be received, and the conversation list will not be updated. |
Receive messages but without notifications | V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE | At this time, it is recommended to display a red dot on the conversation list (without showing the unread count): 1. When a new message is received and the conversation list needs to be updated, obtain the message unread count through the unreadCount in the V2TIMConversation of the conversation. 2. If the unread count is greater than zero, display a red dot instead of the unread number. |
Receive messages but only alert for at messages | V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT | Receive messages normally within the group will only remind you of at messages. |
Only receive at messages | V2TIM_NOT_RECEIVE_MESSAGE_EXCEPT_AT | Only receive at messages on a topic when online or offline |
unreadCount
feature in V2TIMConversation
, it applies only to work groups (Work), public groups (Public), and communities (Community), but not to audio-video groups (AVChatRoom) or meeting groups (Meeting). For more information on group types, see Group System.V2TIMManager.getMessageManager().setGroupReceiveMessageOpt("groupA", V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE, new V2TIMCallback() {@Overridepublic void onSuccess() {// Changed the group message receiving option successfully}@Overridepublic void onError(int code, String desc) {// Failed to change the group message receiving option}});
[[V2TIMManager sharedInstance] setGroupReceiveMessageOpt:@"groupA" opt:V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE succ:^{// Changed the group message receiving option successfully} fail:^(int code, NSString *desc) {// Failed to change the group message receiving option}];
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 groupID = "groupA";V2TIMReceiveMessageOpt opt = V2TIMReceiveMessageOpt::V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE;auto callback = new Callback;callback->SetCallback([=]() {// Changed the group message receiving option successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// Failed to change the group message receiving optiondelete callback;});V2TIMManager::GetInstance()->GetMessageManager()->SetGroupReceiveMessageOpt(groupID, opt, callback);
Was this page helpful?