logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

Manage users

ZEGOCLOUD's In-app Chat (the ZIM SDK) provides the capability of user management, allows users to update their personal profile, such as username, and status updates.

Implementation Process

Manage the extended field

The ZIM SDK provides user extended fields to describe additional properties of users. Developers can use extended fields to customize user attributes through the updateUserExtendedData interface. The usage of extended fields can be defined by developers, and the SDK will only pass the fields without any further processing.

After modifying the extended field properties, users can receive the modification results through ZIMUserExtendedDataUpdatedCallback.

Example
// Update the extended field of user information.
NSString *extendedData = @"";

[zim updateUserExtendedData:extendedData callback:^(NSString * _Nonnull extendedData, ZIMError * _Nonnull errorInfo) {
        
    }];
1
Copied!

Modify User Name

The user name userName is a string used to describe the user's nickname. Developers can configure it through the ZIMUserInfo object. The ZIM SDK supports users to modify their user names after logging in through the updateUserName interface.

After modifying the user name, users can receive the modification results through ZIMUserNameUpdatedCallback.

Example
// Modify the username.
// The `userName` parameter can contain up to 256 bytes in length, with no limit on characters.
NSString *userName = @"";

[zim updateUserName:userName callback:^(NSString * _Nonnull userName, ZIMError * _Nonnull errorInfo) {
        
}];
1
Copied!

Set User Avatar

The ZIM SDK supports users to set or modify their avatars after logging in through the updateUserAvatarUrl interface.

After setting the user avatar, users can receive the setting results through the ZIMUserAvatarUrlUpdatedCallback.

Warning

When a user modifies his/her avatar, other users need to call the queryUsersInfo interface and set the isQueryFromServer parameter in ZIMUsersInfoQueryConfig to true to re-query the user information to obtain the latest avatar.

Example
// Set the user avatar.
// The URL can contain up to 500 bytes in length, with no limit on characters.
NSString *userAvatarUrl = @"";

[zim updateUserAvatarUrl callback:^(NSString * _Nonnull userAvatarUrl, ZIMError * _Nonnull errorInfo) {
        
}];
1
Copied!

Query User Information

Users can query the full information of specified users, including user names and user extended fields, through the queryUsersInfo interface. Only in this interface can users obtain user avatar URLs and user extended field information.

After querying the information, users can receive the query results through the ZIMUsersInfoQueriedCallback.

Example
// Query user information.
// Restrictions: You can query up to 10 user IDs per call or by multiple calls within 10 seconds.
[self.zim queryUsersInfo:@[@"userID_1",@"userID_2"] callback:^(NSArray<ZIMUserFullInfo *> * _Nonnull userList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
        
}];
1
Copied!

Previous

Authentication

Next

Multi-device login