User object
User
is an object that refers to a single user in a chat.
Properties
The User
object has the following properties:
Parameter | Type | Description |
---|---|---|
Id | FSstring | Unique identifier for the channel. Verify the channel ID with our validator. |
UserData | FPubnubChatUserData | Additional data. |
→ UserName | FString | Display name for the user (must not be empty or consist only of whitespace characters). |
→ ExternalID | FString | User's identifier in an external system. You can use it to match id with a similar identifier from an external database. |
→ ProfileUrl | FString | URL of the user's profile picture. |
→ Email | FString | User's email address. |
→ CustomDataJson | FString | JSON providing custom data about the user. Values must be scalar only; arrays or objects are not supported. Filtering App Context data through the custom property is not recommended in SDKs. |
→ Status | FString | Tag that lets you categorize your app users by their current state. The tag choice is entirely up to you and depends on your use case. For example, you can use status to mark users in your chat app as invited , active , or archived . |
→ Type | FString | Tag that lets you categorize your app users by their functional roles. The tag choice is entirely up to you and depends on your use case. For example, you can use type to group users by their roles in your app, such as moderator , player , or support-agent . |
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Methods
You can call the following methods on the User
object.
Click on each method for more details.
Active()
CurrentUser()
Delete()
GetUserData()
GetUserID()
GetChannelRestrictions()
GetChannelsRestrictions()
GetMemberships()
IsPresentOn()
LastActiveTimestamp()
SetRestrictions()
StreamUpdates()
StreamUpdatesOn()
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.
- Ban users if they misbehave.