User object
User
refers to a single user in a chat.
Properties
The User
class has the following properties:
public class User : UniqueChatEntity {
public string Id { get; protected set; }
public string UserName { get; }
public string ExternalId { get; }
public string ProfileUrl { get; }
public string Email { get; }
public string CustomData { get; }
public string Status { get; }
public string DataType { get; }
public bool Active { get; }
public string LastActiveTimeStamp { get; }
}
Parameter | Type | Description |
---|---|---|
Id | string | Unique identifier for the user. |
UserName | string | Display name or username of the user. |
ExternalId | string | Identifier for the user from an external system, such as a database or CRM. |
ProfileUrl | string | URL to the user's profile or avatar image. |
Email | string | User's email address. |
CustomData | string | Any custom data that you want to store for the user. |
Status | string | Current status of the user (e.g., online , offline , away ). |
DataType | string | Type of user's data. |
Active | bool | Returned info on whether the user is active (true ) or not active (false ) on the channel. The returned value depends strictly on how you configure your chat app during initialization - if you set the StoreUserActivityInterval parameter to the default 600000 milliseconds (10 minutes) and the user has been active in the app within the last 10 minutes (based on their LastActiveTimeStamp property), accessing the Active property returns true . |
LastActiveTimeStamp | string | Timestamp for the last time the user was active in a chat app. |
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Events
The User
object has the following event:
// Event triggered when the user is updated
public event Action<User> OnUserUpdated;
Example
An event that is triggered when the user is updated by the server.
user.OnUserUpdated += (user) =>
{
Console.WriteLine("User metadata updated!");
};
Methods
You can call the following methods on the User
object. Click on each method for more details.
AddListenerToUsersUpdate
DeleteUser()
GetChannelRestriction()
GetMemberships()
IsPresentOn()
SetRestriction()
OnUserUpdated
StartListeningForUpdates()
Update()
WherePresent()
Use case
For example, you can use the User
object methods to:
- Create and manage users.
- Let users configure their channel membership.
- Mention others in a conversation.
- Check when was the last time users were online in an app.