V2TIMGroupInfo
object, which is created and returned by the IM SDK and cannot be customized.
The methods to get the group profile are in the V2TIMGroupManager(Android)
/ V2TIMManager(Group)(iOS and macOS)
core class.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:key
of the custom group field. The key
is a string of up to 16 bytes. If the key
is not preconfigured, setting the key-value
will fail.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 | Description |
V2TIM_RECEIVE_MESSAGE | Messages will be received when the user is online, and push notifications will be received when the user is offline. |
V2TIM_NOT_RECEIVE_MESSAGE | No group messages will be received. |
V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE | Messages will be received when the user is online, and no push notifications will be received when the user is offline. |
V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT | Receive messages online, and only receive push for at messages when offline. |
V2TIMReceiveMessageOpt
options can be used to implement group message notification muting:V2TIM_NOT_RECEIVE_MESSAGE
, no group message will be received, and the conversation list will not be updated.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE
.unreadCount
(Android / iOS and macOS / Windows) of V2TIMConversation
.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE
based on the recvOpt
(Android / iOS and macOS / Windows) of V2TIMConversation
.at
messages, and a badge without the unread count will be displayed on the conversation list UI.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT
. After this setting, group messages are received but only at
messages are notified.unreadCount
feature, 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?