• UIKit
  • SDK
  • サーバー API
Chat/
SDK/
Android/
グループ/
SDK
  • Chat SDK のインストール
  • Chat SDK の初期化
  • ログインとログアウト
  • メッセージ
    • Overview
    • メッセージ送信
    • メッセージの受信
    • メッセージの検索
    • メッセージ転送
    • メッセージの変更
    • メッセージ挿入
    • メッセージ削除
    • 過去のメッセージをクリアします
    • メッセージの取り消し
    • オンラインメッセージの送信
    • メッセージの既読レシート
    • クエリーメッセージ
    • ヒント
    • ターゲットグループメッセージ
    • 通知しません
    • Key-Value の拡張
    • 反応
    • 翻訳
    • メッセージの先頭固定表示
  • セッション
    • Overview
    • セッションリスト
    • セッションの取得
    • 未読数
    • セッションの先頭固定表示
    • セッションの削除
    • 下書き
    • マーク
    • セッショングループ
  • グループ
    • Overview
    • グループ管理
    • プロファイル
    • メンバー管理
    • メンバープロファイル
    • プロパティ
    • カウンター
  • コミュニティとトピック
    • コミュニティ管理
    • 権限グループ
  • ユーザー
    • ユーザープロファイル
    • ユーザー状態
    • 友達の管理
    • 友達グループ
    • ブラックリスト
    • Follow
  • ローカル検索
    • メッセージ検索
    • 友達を検索
    • グループの検索
    • グループメンバーの検索
  • シグナリング
  • インターフェースリファレンスドキュメンテーション
    • Java
  • Guideline for Beginners
  • コンソールガイド
    • アプリケーションの作成とアップグレード
    • 基本設定
    • 機能設定
    • アカウント管理
    • グループ管理
    • コールバック設定
  • 製品紹介
    • メッセージ管理
      • シングルチャットメッセージ
      • メッセージの保存
      • オフラインプッシュ
      • グループメッセージ
      • メッセージフォーマット
    • アカウントシステム
      • ログイン認証
      • オンライン状態管理
    • グループ関連
      • グループシステム
      • グループ管理
    • ユーザープロファイルとリレーションシップチェーン
      • 資料管理
      • リレーションシップチェーン管理
  • 購入ガイド
    • 課金の概要
    • 価格
  • エラーコード
このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

プロファイル

Overview

The group profile refers to the information about the group, such as group ID, group type, custom group field, and the number of joined members. It is saved in the V2TIMGroupInfo object, which is created and returned by the IM SDK and cannot be customized.

Getting the Group Profile

Call 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.
Sample code:
Android
iOS and macOS
Windows
V2TIMManager.getGroupManager().getGroupsInfo(groupIDList, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
@Override
public void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {
// Obtained the group profile successfully
}

@Override
public 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 successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to obtain the group profile
delete callback;
});
V2TIMManager::GetInstance()->GetGroupManager()->GetGroupsInfo(groupIDList, callback);

Modifying Group Profiles

Call setGroupInfo (Android / iOS and macOS / Windows) to modify the group profile.
If you have called 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).
Member roles that can modify the group profile vary by group type as follows:
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
Caution
Not all the fields of the group profile V2TIMGroupInfo can be modified, but only those writable.
Sample code:
Android
iOS and macOS
Windows
// Sample code: Modify group profile
V2TIMGroupInfo v2TIMGroupInfo = new V2TIMGroupInfo();
v2TIMGroupInfo.setGroupID("Group ID of the group to be modified");
v2TIMGroupInfo.setFaceUrl("http://xxxx");
V2TIMManager.getGroupManager().setGroupInfo(v2TIMGroupInfo, new V2TIMCallback() {
@Override
public void onSuccess() {
// Modified the group profile successfully
}

@Override
public 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 successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to modify the group profile
delete callback;
});

V2TIMManager::GetInstance()->GetGroupManager()->SetGroupInfo(info, callback);

Setting a Custom Group Field

The 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.
Unlike setting other fields in V2TIMGroupInfo, setting the custom group field involves two steps:
1. In the Console, configure the key for the Custom Group Definition field. The key is of type string and its length should not exceed 16 bytes. If the key is not pre-configured, attempting to directly set the key-value will fail. Configuration path: Applications > Your App > Chat > Configuration > Group Configuration > Custom Group Field.
2. Call the setGroupInfo API to set the field with up to 512 bytes.
Caution
1. You can set up to ten custom fields, which cannot be deleted and whose name and type cannot be changed.
2. The custom field is mainly used to ensure compatibility with v1 and v2. If you use the API on v2, we recommend you use the 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.

Setting the Group Message Receiving Option

Any group member can call the 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
Setting different 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
Within a specified time window, all messages for the logged-in account can be received online; there will be no push when offline.
Note:
In the above implementations, if it requires the 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.
Sample code:
Android
iOS and macOS
Windows
V2TIMManager.getMessageManager().setGroupReceiveMessageOpt("groupA", V2TIMMessage.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE, new V2TIMCallback() {
@Override
public void onSuccess() {
// Changed the group message receiving option successfully
}

@Override
public 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 successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to change the group message receiving option
delete callback;
});

V2TIMManager::GetInstance()->GetMessageManager()->SetGroupReceiveMessageOpt(groupID, opt, callback);