Instant Messaging
Unity
User Tutorial
Product Introduction
Overview
Features
Limits
Main Features
Account integration and login
Basic Message Features
Team Features
Chat Room Features
Chat Room Tags
Multi-terminal login
Quality Data Monitor
Development Integration
Overview
Integration Mode
Initialization
Login and Logout
Messaging
Team Features
Recent Session
History
User Information Management
User Relationship Management
System Notification
Audio Recording and Playback
NOS Cloud Storage Service
Client Anti-Spam
Event Subscription
Push Notification Service
Chat Room
API Reference
Status Code

User Information Management

Update time: 2021/09/25 22:32:12

CommsEase provides the service of hosting user data, including birthday, Email, gender, phone number, signature and extension field. The user data is managed via NIM.User.UserAPI. UserNameCard indicates user data and defines all data of a user.

User Data

Description of NIM.User.UserNameCard:

Property Description
AccountId User account
NickName Nickname
IconUrl Avatar URL
Signature Signature
Gender Gender: 0 means female; 1 means male.
Email Email
Birthday Birthday
Mobile Phone number
ExpandedData Expansion information
CreateTime Creation timestamp
UpdatedTime Final update timestamp

Get Local User Data

Get user data in bulk from locally cached data

  • API prototype
/// <summary>
///Get user card of designated account in cache data
/// </summary>
/// <param name="accountIdList">List of user account IDs</param>
/// <param name="resultDelegate">Callback for querying results</param>
public static void GetUserNameCard(List<string> accountIdList, GetUserNameCardResultDelegate resultDelegate)
  • Example
NIM.User.UserAPI.GetUserNameCard(new List<string>() { "id1","id2" }, OnGetNameCardCompleted);

private void OnGetNameCardCompleted(UserNameCard[] list)
{
    if (list != null && list.Any())
    {
        //Query successfully, and process query results
    }
}

Get User Data from the Server

User data is acquired from server and usually called when there is not local user data. After acquisition, SDK will update local database. 150 users can be acquired at most each time. The upper level may get user data in batch in the event of large quantity.

  • API prototype
/// <summary>
///Query user card of designated account online
/// </summary>
/// <param name="accountIdList">List of user account IDs</param>
/// <param name="resultDelegate"></param>
public static void QueryUserNameCardOnline(List<string> accountIdList, GetUserNameCardResultDelegate resultDelegate)
  • Example
NIM.User.UserAPI.QueryUserNameCardOnline(new List<string>() { "id1","id2" }, OnGetNameCardCompleted);

Notes: User data can be acquired from server in bulk via this interface. Considering user experience and flow cost, it is recommended not to invoke this interface frequently. For the pages under which the real-time performance requirement is not high, it is suggested to call the interface of reading local cache.

Update Personal Information

To update your user data, first construct theUserNameCardobject, then set the attributes that need to be updated, after that, callNIM.User.UserAPIUpdateMyCardto perform the update.

  • API prototype
/// <summary>
/// Update user cards
/// </summary>
/// <param name="card"></param>
/// <param name="d"></param>
public static void UpdateMyCard(UserNameCard card, UpdateNameCardResultDelegate d)
  • Example
private void UpdateMyInfo()
{
    UserNameCard card = new UserNameCard();
    card.AccountId = "MYSELF ID";
    card.Birthday = "1990.01.01";
    card.Email = "xxxxxx@xxxx.com";
    card.Mobile = "123456789";
    card.NickName = "NEW NICKNAME";
    card.Signature = "SIGNATURE";
    card.Gender = 1;
    NIM.User.UserAPI.UpdateMyCard(_card, OnUpdateMyNamecard);
}

private void OnUpdateMyNamecard(ResponseCode response)
{
    //Process operation results
}

Notification for User Data Change

The event NIM.User.UserAPI.UserNameCardChangedHandler is registered to get notification for data change of all users.

  • Example
NIM.User.UserAPI.UserNameCardChangedHandler += OnUserChanged;

private void OnUserChanged(object sender, UserNameCardChangedArgs e)
{
    //Process user data change. The parameter e includes detailed information of a user.
}

Except your "user data", SDK cannot ensure real-time information updating for other users. Other user data update occasion:

  • Call the interface QueryUserNameCardOnline to get user data online.

  • Receive messages from the user

  • When the program is start up again, information of friends will be synchronized.

Was this topic helpful?
Yes
No
  • User Data
  • Get Local User Data
  • Get User Data from the Server
  • Update Personal Information
  • Notification for User Data Change