---
source_url: https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/membership
title: Membership object
updated_at: 2026-06-15T09:14:05.511Z
---

> 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


# Membership object

`Membership` represents a single user-channel relationship in a chat.

## Properties

The `MembershipImpl` class implements the `Membership` protocol and takes the following properties:

```swift
extension MembershipImpl: Membership {
    public var chat: ChatImpl
    public var channel: ChannelImpl
    public var user: UserImpl
    public var custom: [String: JSONCodableScalar]?
    public var status: String?
    public var type: String?
    public var eTag: String?
    public var updated: String?
    public var lastReadMessageTimetoken: Timetoken?

     ...
}
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| chat | ChatImpl | Optional |  | Reference to the main `Chat` protocol. |
| channel | ChannelImpl | Optional |  | [ChannelImpl object](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/channel). |
| user | UserImpl | Optional |  | [UserImpl object](https://www.pubnub.com/docs/chat/swift-chat-sdk/learn/chat-entities/user). |
| custom | [String: | Optional |  | Any custom properties or metadata associated with the user-channel relationship in the form of a dictionary of key-value pairs. [App Context filtering language](https://www.pubnub.com/docs/general/metadata/filtering) doesn’t support filtering by custom properties. |
| status | String | Optional |  | Status of the membership. |
| type | String | Optional |  | Type of the membership. |
| eTag | String | Optional |  | Caching value that changes whenever the `MembershipImpl` object changes. |
| updated | String | Optional |  | Last time the `MembershipImpl` object was changed. |
| lastReadMessageTimetoken | Timetoken | Optional |  | Timetoken of the last message a user read on a given channel. |

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

## Methods

You can call the following methods and properties on the `Membership` object.

Click on each method or property for more details.

* [delete()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#delete-membership)
* [getUnreadMessagesCount()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread#get-unread-messages-count-one-channel)
* [lastReadMessageTimetoken](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread#get-last-read-message)
* [setLastReadMessage()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread#mark-messages-as-read-one-channel)
* [setLastReadMessageTimetoken()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread#mark-messages-as-read-one-channel)
* [update()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#update)

## Event listeners

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

Click on each method for more details.

* [onDeleted()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#get-updates)
* [onUpdated()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#get-updates)
* [streamUpdatesOn()](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#get-updates)

## Use case

`Membership` methods enable:

* [Updating](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#update) user-channel relationships and [getting updates](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/channels/membership#get-updates) on changes
* Tracking the [last message read](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread#mark-messages-as-read-one-channel) by a user on a channel
* Getting the count of [unread messages](https://www.pubnub.com/docs/chat/swift-chat-sdk/build/features/messages/unread#get-unread-messages-count-one-channel) for a user