---
source_url: https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/user
title: User object
updated_at: 2026-06-16T12:48:56.751Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# User object

`User` represents a single user in a chat.

## Properties

The `UserImpl` class implements the `User` protocol and takes following properties:

```swift
extension UserImpl: User {
  public var chat: ChatImpl
  public var id: String
  public var name: String?
  public var externalId: String?
  public var profileUrl: String?
  public var email: String?
  public var custom: [String: JSONCodableScalar]?
  public var status: String?
  public var type: String?
  public var updated: String?
  public var eTag: String?
  public var lastActiveTimestamp: TimeInterval?
  public var active: Bool
}
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| chat | ChatImpl | Optional |  | Reference to the main `Chat` protocol. |
| id | String | Optional |  | [Unique ID](https://www.pubnub.com/docs/general/setup/users-and-devices) of the user. |
| name | String | Optional |  | Display name or username of the user (must not be empty or consist only of whitespace characters). |
| externalId | String | Optional |  | Identifier for the user from an external system, such as a third-party authentication provider or a user directory. |
| profileUrl | String | Optional |  | URL to the user’s profile or avatar image. |
| email | String | Optional |  | User’s email address. |
| custom | [String: | Optional |  | Any custom properties or metadata associated with the user in the form of a JSON. [App Context filtering language](https://www.pubnub.com/docs/general/metadata/filtering) doesn’t support filtering by custom properties. |
| status | String | Optional |  | Current status of the user, like `online`, `offline`, or `away`. |
| type | String | Optional |  | Type of the user, like `admin`, `member`, `guest`. |
| updated | String | Optional |  | Timestamp (a number of seconds since January 1, 1970) for the last time the user information was updated or modified. |
| eTag | String | Optional |  | The entity tag (`ETag`) that was returned by the server. It is a random string that changes with each data update. |
| lastActiveTimestamp | TimeInterval | Optional |  | Timestamp for the last time the user was active in a chat app. |
| active | Bool | Optional |  | Indicates whether the user is currently active (at the time of obtaining this `User` object). |

:::tip API limits
To learn about the maximum length of parameters used to set user metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-user-metadata).
:::

## Methods

You can call the following methods on the `User` object.

Click on each method for more details.

* [delete()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/delete)
* [getMembership()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#get-single-membership)
* [getMemberships()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#get-membership)
* [isMemberOf()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#check-if-user-belongs-to-channel)
* [isPresentOn()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence#check-users-channel-presence)
* [update()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/updates#update-user-details)
* [wherePresent()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence#return-channels-where-user-is-present)

## Event listeners

You can call the following event listener methods on the `User` object.

Click on each method for more details.

* [onDeleted()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/updates#get-user-updates)
* [onInvited()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/invite#listen-to-invite-events)
* [onMentioned()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/mentions#show-notifications-for-mentions)
* [onRestrictionChanged()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/moderation-user#listen-to-restriction-changes)
* [onUpdated()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/updates#get-user-updates)
* [streamUpdatesOn()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/updates#get-user-updates)

## Use case

`User` methods enable:

* [Creating and managing](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/create) users
* Configuring channel [memberships](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership)
* [Mentioning](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/mentions) others in conversations
* Checking user [presence](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/users/presence) status