tencent cloud

Chat

News and Announcements
Release Notes
Announcements
Product Introduction
Overview
Basic Concepts
Scenarios
Features
Account System
User Profile and Relationship Chain
Message Management
Group Related
Official Account
Audio/Video Call
Use Limits
Purchase Guide
Billing Overview
Pricing
Purchase Instructions
Renewal Guide
Service Suspension Explanation
Refund Policy
Development Guidelines
Demo Zone
Activate Service
Free Demos
Quick Run
Download
SDK and Demo Source Code
Update Log
Chat Interaction (UI Included)
TUIKit Introduction
Getting Started
Full-feature Integration
Single-function Integration
Build with AI
Build Basic Interfaces
More Features
Customizing Appearance
Internationalization
Push Service
Overview
Noun explanation
Activate the Service
Quick Start
Manufacturer Channel
Statistics
Troubleshooting Tool
Client APIs
REST API
Push Callback
Advanced Features
Release Notes
Error Codes
FAQS
Desk
Overview
Quick Start
Integration Guide
Admin Operation Manual
Agent Manual
More Practices
Live Streaming Setup Guide
AI Chatbot
Super Large Entertainment and Collaboration Community
Discord Implementation Guide
How to Integrate Chat into Games
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
No UI Integration
Quick Start
SDK Integration
Initialization
Login and Logout
Message
Conversation
Group
Community Topic
User Profile and Relationship Chain
Offline Push
Cloud Search
Local Search
Official Channel Management
Client APIs
JavaScript
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
Server APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
Console Guide
New Console Introduction
Creating and Upgrading an Application
Basic Configuration
Feature Configuration
Account Management
Group Management
Official Channel Management
Webhook Configuration
Usage
Viewing Guide for Resource Packages
Real-Time Monitor
Auxiliary Development Tools
Access Management
Advanced Features
FAQs
uni-app FAQs
Purchase
SDK
Account Authentication
User Profile and Relationship Chain
Message
Group
Audio-Video Group
Nickname and Profile Photo
Security Compliance Certification
Service Level Agreement
Security Compliance Certification
Chat Policies
Privacy Policy
Data Privacy and Security Agreement
Migration
Migration Solutions
Migration Solutions Lite
Error Codes
Contact Us

Flutter

PDF
Focus Mode
Font Size
Last updated: 2025-04-16 15:00:22

Overview

Users can set and get their nicknames, profile photos, and statuses as well as the profile information of non-friend users. The methods are in the TencentImSDKPlugin.v2TIMManager.getFriendshipManager() core class.

Relationship Chain Event Listener

Call the addFriendListener API (details) to add a contacts event listener.
To stop receiving contacts events, call the removeFriendListener API (details) to remove the contacts event listener.
Note:
You need to set the contacts event listener in advance to receive event notifications.
Sample code:
// Set the contacts listener
V2TimFriendshipListener listener = V2TimFriendshipListener(
onBlackListAdd: (List<V2TimFriendInfo> infoList) async {
// Callback for adding a user to the blocklist
// infoList: List of information of the user added
},
onBlackListDeleted: (List<String> userList) async {
// Callback for removing users from the blocklist
// userList: List of IDs of the users deleted
},
onFriendApplicationListAdded:
(List<V2TimFriendApplication> applicationList) async {
// Callback for the increase of friend requests
// applicationList: List of the information of new friend requests
},
onFriendApplicationListDeleted: (List<String> userIDList) async {
// Callback for the decrease of friend requests
// userIDList: List of user IDs corresponding to the friend requests decreased
},
onFriendApplicationListRead: () async {
// Callback for read friend request
},
onFriendInfoChanged: (List<V2TimFriendInfo> infoList) async {
// Callback for friend information changes
// infoList: list of friends whose information changes
},
onFriendListAdded: (List<V2TimFriendInfo> users) async {
// Callback for the increase of users in the friend list
// users: list of users added
},
onFriendListDeleted: (List<String> userList) async {
// Callback for the decrease of users in the friend list
// userList: list of users deleted
},
);
TencentImSDKPlugin.v2TIMManager
.getFriendshipManager()
.addFriendListener(listener: listener); // Add a contacts listener
// Remove the contacts listener
friendshipManager.removeFriendListener(listener: friendshipListener);

User Profile Management

Querying and modifying your own profile

Call the getUsersInfo API (details) with the userIDList parameter set to a user's UserID to query the user's profile.
Call the setSelfInfo API (details) to modify a user's profile.
After the profile is modified successfully, you will receive the onSelfInfoUpdated callback (details).
Sample code:
// Obtain a user's personal profile
V2TimValueCallback<String> self = await TencentImSDKPlugin.v2TIMManager.getLoginUser();
TencentImSDKPlugin.v2TIMManager.getUsersInfo(userIDList: [self.data]);

// Set the user's profile
TencentImSDKPlugin.v2TIMManager.setSelfInfo(userFullInfo: V2TimUserFullInfo(nickName: "",role: 0,faceUrl: ""));


Querying the user profile of a non-friend user

Call the getUsersInfo API (details) with the userIDList parameter set to a non-friend user's UserID to query the non-friend user's profile.
Note:
The profile of a non-friend user cannot be modified.

Querying and modifying a friend's profile

Call the getFriendsInfo API (details) to query the profile of the specified friend. The relationship between the user and the friend can be obtained through the relation field of the V2TIMFriendInfoResult in the callback:
relation
Relationship
V2TIM_FRIEND_RELATION_TYPE_NONE
Not a friend
V2TIM_FRIEND_RELATION_TYPE_BOTH_WAY
Two-way friend
V2TIM_FRIEND_RELATION_TYPE_IN_MY_FRIEND_LIST
The user is in your contacts.
V2TIM_FRIEND_RELATION_TYPE_IN_OTHER_FRIEND_LIST
You are in the user's contacts.
// Get friend information
V2TimValueCallback<List<V2TimFriendInfoResult>> friendsInfo = await friendshipManager.getFriendsInfo(userIDList: []);
Call the setFriendInfo API (details) to modify the information of a friend such as remarks.
// Set friend information
TencentImSDKPlugin.v2TIMManager.setSelfInfo(userFullInfo: V2TimUserFullInfo(nickName: "",role: 0,faceUrl: ""));

FAQs

Why can't the SDK enhanced edition get the latest user profiles?

There are two types of user profile updates in the enhanced SDK:
Friend's profile: when the profile of a friend is updated, the backend will send a system notification to the SDK, so the friend's profile will be updated in real time.
Stranger's profile: when the profile of a stranger is updated, the backend will not send any system notification because the stranger is not a friend of yours, so the stranger's profile will not be updated in real time. To avoid sending a network request to the backend every time the user profile is obtained, the SDK adds a caching logic, setting a 10-minute interval between pulls of the same user's profile from the backend.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback