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

ユーザープロファイル

Feature Description

Users can query the information of themselves, friends, and non-friend users. They can also change their nicknames, profile photos, and statuses, as well as friend remarks and list.

Relationship Event Listener

Call addFriendListener (Android / iOS and Mac / Windows) to add a relationship event listener.
To stop receiving relationship events, call removeFriendListener (Android / iOS and Mac / Windows) to remove the relationship event listener.
Note:
You need to set the relationship event listener in advance to receive event notifications.
Sample code:
Android
iOS and macOS
Windows
// Add a relationship listener
V2TIMManager.getFriendshipManager().addFriendListener(listener);
// Remove the relationship listener
V2TIMManager.getFriendshipManager().removeFriendListener(listener);
// Add a relationship listener
// `self` is id<V2TIMFriendshipListener>.
[[V2TIMManager sharedInstance] addFriendListener:self];

// Remove the relationship listener
[[V2TIMManager sharedInstance] removeFriendListener:self];
class FriendshipListener final : public V2TIMFriendshipListener {
// Member...
};

// Add a relationship event listener. Keep `friendshipListener` valid before the listener is removed to ensure event callbacks are received.
FriendshipListener friendshipListener;
V2TIMManager::GetInstance()->GetFriendshipManager()->AddFriendListener(&friendshipListener);

// Remove the relationship listener
V2TIMManager::GetInstance()->GetFriendshipManager()->RemoveFriendListener(&friendshipListener);

Query and Modify User Profile

Your Own Profile

Call the getUsersInfo API (Android / iOS and Mac / Windows) and enter a user's UserID for the userIDList parameter to query the user's profile.
Sample code:
Android
iOS and macOS
Windows
// Obtain a user's personal profile
String loginUser = V2TIMManager.getInstance().getLoginUser();
List<String> userIDList = new ArrayList<>();
userIDList.add(loginUser);
V2TIMManager.getInstance().getUsersInfo(userIDList, new V2TIMValueCallback<List<V2TIMUserFullInfo>>() {
@Override
public void onSuccess(List<V2TIMUserFullInfo> profiles) {
// User's profile obtained successfully
}
@Override
public void onError(int code, String desc) {
// Failed to obtain the user's profile
}
});
// Obtain a user's personal profile
NSString *loginUser = [[V2TIMManager sharedInstance] getLoginUser];
[[V2TIMManager sharedInstance] getUsersInfo:@[loginUser] succ:^(NSArray<V2TIMUserFullInfo *> *infoList) {
// User's profile obtained successfully
} fail:^(int code, NSString *desc) {
// Failed to obtain the user's 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_;
};

V2TIMString loginUser = V2TIMManager::GetInstance()->GetLoginUser();
V2TIMStringVector userIDList;
userIDList.PushBack(loginUser);

auto callback = new ValueCallback<V2TIMUserFullInfoVector>{};
callback->SetCallback(
[=](const V2TIMUserFullInfoVector& userFullInfoList) {
// User's profile obtained successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to obtain the user's profile
delete callback;
});

V2TIMManager::GetInstance()->GetUsersInfo(userIDList, callback);
Call the setSelfInfo API (Android / iOS and Mac / Windows) to modify a user's profile. A user's profile includes the user's nickname, profile photo, status, gender, birth date, and friend request approval method. For more information, see the definitions of the V2TIMUserFullInfo class (Android / iOS and macOS / Windows). After the profile is modified successfully, you will receive the onSelfInfoUpdated callback (Android / iOS and Mac / Windows).
Sample code:
Android
iOS and macOS
Windows
// Set the user's profile
V2TIMUserFullInfo info = new V2TIMUserFullInfo();
info.setNickname("nickName");
info.setFaceUrl("faceUrl");
V2TIMManager.getInstance().setSelfInfo(info, new V2TIMCallback() {
@Override
public void onSuccess() {
// User's profile set successfully
}

@Override
public void onError(int code, String desc) {
// Failed to set the user's profile
}
});

// Listen for the callback for a user's profile change
V2TIMManager.getInstance().addIMSDKListener(new V2TIMSDKListener() {
@Override
public void onSelfInfoUpdated(V2TIMUserFullInfo info) {
// Received the callback for a user's profile change
}
});
// Set the user's profile
V2TIMUserFullInfo *info = [[V2TIMUserFullInfo alloc] init];
info.nickName = @"nickName";
info.faceURL = @"faceURL";
[[V2TIMManager sharedInstance] setSelfInfo:info succ:^{
// User's profile set successfully
} fail:^(int code, NSString *desc) {
// Failed to set the user's profile
}];

// Listen for the callback for a user's profile change
[[V2TIMManager sharedInstance] addIMSDKListener:self];
- (void)onSelfInfoUpdated:(V2TIMUserFullInfo *)Info {
// Received the callback for a user's profile change
}
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_;
};

V2TIMUserFullInfo info;
info.nickName = u8"nickName";
info.faceURL = u8"faceUrl";
info.modifyFlag = V2TIMUserInfoModifyFlag::V2TIM_USER_INFO_MODIFY_FLAG_NICK |
V2TIMUserInfoModifyFlag::V2TIM_USER_INFO_MODIFY_FLAG_FACE_URL;

auto callback = new Callback{};
callback->SetCallback(
[=]() {
// User's profile set successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to set the user's profile
delete callback;
});

V2TIMManager::GetInstance()->SetSelfInfo(info, callback);

// Listen for the callback for a user's profile change
class SDKListener final : public V2TIMSDKListener {
public:
SDKListener() = default;
~SDKListener() override = default;

void OnSelfInfoUpdated(const V2TIMUserFullInfo& info) override {
// Received the callback for a user's profile change
}
// Other members …
};
// Add an event listener. Keep `sdkListener` valid before the listener is removed to ensure event callbacks are received.
SDKListener sdkListener;
V2TIMManager::GetInstance()->AddSDKListener(&sdkListener);

Friend Profile

Call the getFriendsInfo API (Android / iOS and macOS / Windows) to query the profile of the specified friend. And you can call setFriendInfo API (Android / iOS and Mac / Windows) to modify the profile of the specified friend. For more information, see Friend Management.

Non-friend Profile

Call the getUsersInfo API (Android / iOS and Mac / Windows) and enter the UserID of a non-friend user for the userIDList parameter to query the profile of the non-friend user.
Note:
1. The profile of a non-friend user cannot be modified.
2. When the profile of a non-friend user is updated, the backend cannot send any system notification to the SDK because there is no friend relationship, so the non-friend user's profile will not be updated in real time in SDK. To avoid sending a network request to the server every time the user profile is obtained and save network resources, the SDK adds a caching logic, setting a 10-minute interval between proactive pulls of the same user's profile from the server.
Sample code:
Android
iOS and macOS
Windows
List<String> userIDList = new ArrayList<>();
userIDList.add("userA");
V2TIMManager.getInstance().getUsersInfo(userIDList, new V2TIMValueCallback<List<V2TIMUserFullInfo>>() {
@Override
public void onSuccess(List<V2TIMUserFullInfo> profiles) {
// Obtained the profile of the non-friend user successfully
}

@Override
public void onError(int code, String desc) {
// Failed to obtain the profile of the non-friend user
}
});
// Get the profile of a non-friend user
[[V2TIMManager sharedInstance] getUsersInfo:@[@"userA"] succ:^(NSArray<V2TIMUserFullInfo *> *infoList) {
// Obtained the profile of the non-friend user successfully
} fail:^(int code, NSString *desc) {
// Failed to obtain the profile of the non-friend user
}];
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 userIDList;
userIDList.PushBack(u8"userA");

auto callback = new ValueCallback<V2TIMUserFullInfoVector>{};
callback->SetCallback(
[=](const V2TIMUserFullInfoVector& userFullInfoList) {
// Obtained the profile of the non-friend user successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to obtain the profile of the non-friend user
delete callback;
});

V2TIMManager::GetInstance()->GetUsersInfo(userIDList, callback);

Subscribe to Non-friend Profile

You can use the subscribeUserInfo API (Android / iOS and Mac / Windows) to subscribe to the profiles of non-friend users. Once successfully subscribed, the SDK will notify you of any changes to the subscribed user's profile via the onUserInfoChanged (Android / iOS and Mac / Windows) callback.
By subscribing to non-friend user profiles, you can stay informed of changes to specific non-friend user profiles in real-time. You do not need to subscribe for friends' profiles or your own profile. Changes to those profiles will automatically be notified to you via the onFriendInfoChanged or onSelfInfoUpdated callback.
Note:
This feature is only available to Premium edition customers. After purchasing the Premium Edition and enabling "User Profile Change Subscription" in the Console, you can use this feature. The switch path is: Applications > Your App > Chat > Configuration > Login and Message > User Profile Change Subscription.
This feature is available only in SDK enhanced edition v7.4 or later.
The subscription list allows a maximum of 200 subscriptions. After the limit is exceeded, the earliest subscribed user will be automatically eliminated (subscribing to friends will also occupy these 200 places).
The frequency limit defaults to a maximum of 20 requests within 5 seconds, and the maximum number of users for a single request must not exceed 100.
Sample code:
Android
iOS & Mac
Windows
List<String> useridList = Arrays.asList("useridA", "useridB", "useridC");
V2TIMManager.getInstance().subscribeUserInfo(useridList, new V2TIMCallback() {
@Override
public void onSuccess() {
// Subscription to user profile successful.
}

@Override
public void onError(int code, String desc) {
// Subscription to user profile failed.
}
});
[V2TIMManager.sharedInstance subscribeUserInfo:@[@"useridA", @"useridB", @"useridC"]
succ:^ {
// Subscription to user profile successful.
} fail:^(int code, NSString *desc) {
// Subscription to user profile failed.
}];
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_;
};

V2TIMStringVector userIDList;
userIDList.PushBack(u8"useridA");
userIDList.PushBack(u8"useridB");

auto callback = new Callback{};
callback->SetCallback(
[=]() {
// Subscription to user profile successful.
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Subscription to user profile failed.
delete callback;
});

V2TIMManager::GetInstance()->SubscribeUserInfo(userIDList, callback);

Unsubscribe to Non-friend Profile

If you do not want to receive notifications of changes to subscribed user profiles, you can call the unsubscribeUserInfo API (Android / iOS and Mac / Windows) to cancel the subscription for certain users.
When the user list in the API parameters is empty, all current subscriptions will be canceled.
Note:
This feature is only available to Advanced edition customers. After purchasing the Premium Edition and enabling "User Profile Change Subscription" in the Console, you can use this feature. The switch path is: Applications > Your App > Chat > Configuration > Login and Message > User Profile Change Subscription.
This feature is available only in SDK enhanced edition v7.4 or later.
The API frequency limit defaults to a maximum of 20 requests within 5 seconds, and the maximum number of users for a single request must not exceed 100.
Sample code:
Android
iOS
Windows
List<String> useridList = Arrays.asList("useridA", "useridB", "useridC");
V2TIMManager.getInstance().unsubscribeUserInfo(useridList, new V2TIMCallback() {
@Override
public void onSuccess() {
// Unsubscription to user profile successful.
}

@Override
public void onError(int code, String desc) {
// Unsubscription to user profile failed.
}
});
[V2TIMManager.sharedInstance unsubscribeUserInfo:@[@"useridA", @"useridB", @"useridC"]
succ:^ {
// Unsubscription to user profile successful.
} fail:^(int code, NSString *desc) {
// Unsubscription to user profile failed.
}];
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_;
};

V2TIMStringVector userIDList;
userIDList.PushBack(u8"useridA");
userIDList.PushBack(u8"useridB");

auto callback = new Callback{};
callback->SetCallback(
[=]() {
// Unsubscription to user profile successful.
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Unsubscription to user profile failed.
delete callback;
});

V2TIMManager::GetInstance()->UnsubscribeUserInfo(userIDList, callback);

User Profile Change Notification

User profile changes can be categorized into three types based on different user types:
1. Changes to your own profile: Notifications are received through the onSelfInfoUpdated (Android / iOS and Mac / Windows) callback.
2. Changes to a friend's profile: Notifications are received through the onFriendInfoChanged (Android / iOS and Mac / Windows) callback.
3. Changes to a subscribed user's (non-friend) profile: Notifications are received through the onUserInfoChanged (Android / iOS and Mac / Windows) callback.
To set up the onSelfInfoUpdated and onUserInfoChanged callbacks, call addIMSDKListener (Android / iOS and Mac / Windows) to add an SDK listener. For the onFriendInfoChanged callback, call addFriendListener (Android / iOS and Mac / Windows) to add a relationship listener.
Caution
Profile changes will only be notified through the onUserInfoChanged callback if the users meet the following conditions:
1. Users who have successfully subscribed using subscribeUserInfo.
2. Users who are not friends.
Sample code:
Android
iOS & Mac
Windows
V2TIMSDKListener v2TIMSDKListener = new V2TIMSDKListener() {
@Override
public void onSelfInfoUpdated(V2TIMUserFullInfo info) {
// Receive notification of changes to your own profile
}
@Override
public void onUserInfoChanged(List<V2TIMUserFullInfo> infoList) {
// Receive notification of changes to subscribed user (non-friend) profiles
}
};

// Add an SDK listener
V2TIMManager.getInstance().addIMSDKListener(v2TIMSDKListener);


V2TIMFriendshipListener v2TIMFriendshipListener = new V2TIMFriendshipListener() {
@Override
public void onFriendInfoChanged(List<V2TIMFriendInfo> infoList) {
// Receive notification of changes to friend profiles
}
};

// Add a relationship listener
V2TIMManager.getFriendshipManager().addFriendListener(v2TIMFriendshipListener);
// Add an SDK listener
[[V2TIMManager sharedInstance] addIMSDKListener:self];

- (void)onSelfInfoUpdated:(V2TIMUserFullInfo *)info {
// Receive notification of changes to your own profile
}

- (void)onUserInfoChanged:(NSArray<V2TIMUserFullInfo *> *)infoList {
// Receive notification of changes to subscribed user (non-friend) profiles
}


// Add a relationship listener
[[V2TIMManager sharedInstance] addFriendListener:self];

- (void)onFriendProfileChanged:(NSArray<V2TIMFriendInfo *> *)infoList {
// Receive notification of changes to friend profiles
}
class SDKListener final : public V2TIMSDKListener {
public:
SDKListener() = default;
~SDKListener() override = default;

void OnSelfInfoUpdated(const V2TIMUserFullInfo& Info) override {
// Receive notification of changes to your own profile
}
void OnUserInfoChanged(const V2TIMUserFullInfoVector& InfoList) override {
// Receive notification of changes to subscribed user (non-friend) profiles
}
// Other members ...
};

// Add an SDK event listener. Keep `sdkListener` valid before the listener is removed to ensure event callbacks are received.
SDKListener sdkListener;
V2TIMManager::GetInstance()->AddSDKListener(&sdkListener);


class FriendshipListener final : public V2TIMFriendshipListener {
public:
FriendshipListener() = default;
~FriendshipListener() override = default;
void OnFriendInfoChanged(const V2TIMFriendInfoVector& InfoList) override {
// Receive notification of changes to friend profiles
}
// Other members ...
};

// Add a relationship event listener. Keep `friendshipListener` valid before the listener is removed to ensure event callbacks are received.
SDKListener sdkListener;
FriendshipListener friendshipListener;
V2TIMManager::GetInstance()->GetFriendshipManager()->AddFriendListener(&friendshipListener);