App Context API for C# SDK

This page describes App Context (formerly Objects v2). To upgrade from Objects v1, refer to the migration guide.

App Context provides easy-to-use, serverless storage for user and channel data that you need to build reliable, scalable applications. Use App Context to store metadata about your application users and channels, and their membership associations, without the need to run your own databases.

PubNub triggers events when object data is set, updated, or removed. Setting the same data that already exists does not trigger an event. Clients can receive these events in real time and update the front end accordingly.

Starting a new app? Use DataSync

DataSync is the successor to App Context. It covers the same users, channels, and memberships, and adds typed schemas, JSON Patch updates with ETags, field-level projections, and per-class expiry. Refer to the feature-by-feature comparison for details.

DataSync is currently available to new accounts and to accounts that are not actively using App Context. If your keysets already use App Context, keep using it for now. App Context remains fully supported.

Request execution

Use try/catch when working with the C# SDK.

If a request has invalid parameters (for example, a missing required field), the SDK throws an exception. If the request reaches the server but fails (server error or network issue), the error details are available in the returned status.

1try
2{
3 PNResult<PNPublishResult> publishResponse = await pubnub.Publish()
4 .Message("Why do Java developers wear glasses? Because they can't C#.")
5 .Channel("my_channel")
6 .ExecuteAsync();
7
8 PNStatus status = publishResponse.Status;
9
10 Console.WriteLine("Server status code : " + status.StatusCode.ToString());
11}
12catch (Exception ex)
13{
14 Console.WriteLine($"Request can't be executed due to error: {ex.Message}");
15}

User​

Get metadata for all users​

Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.

Required keyset configuration
To get all channel and user metadata, you must uncheck the Disallow Get All Channel Metadata and Disallow Get All User Metadata checkboxes in the App Context section of your keyset configuration in the Admin Portal.

Method(s)​

To Get All UUID Metadata you can use the following method(s) in the C# SDK:

1pubnub.GetAllUuidMetadata()
2 .IncludeCustom(bool)
3 .IncludeCount(bool)
4 .Page(PNPageObject)
5 .Sort(List<string>)
6 .Filter(string)
7 .Limit(int)
IncludeCustom#
Type: bool
Whether to include the Custom object in the response.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).
Filter#
Type: string
Filter expression. Only matching objects are returned. See filtering.
Limit#
Type: int
Number of objects to return. Default/Max: 100.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14try
15{
show all 36 lines

Response​

1{
2 "Uuids": [
3 {
4 "Uuid": "uuid-1",
5 "Name": "John Doe",
6 "Email": "jack@twitter.com",
7 "ExternalId": null,
8 "ProfileUrl": null,
9 "Custom": null,
10 "Updated": "2020-06-17T16:28:14.060718Z"
11 },
12 {
13 "Uuid": "uuid-2",
14 "Name": "Bob Cat",
15 "Email": "bobc@example.com",
show all 29 lines

Get user metadata​

Returns metadata for the specified UUID, optionally including the custom data object for each.

Method(s)​

To Get UUID Metadata you can use the following method(s) in the C# SDK:

1pubnub.GetUuidMetadata()
2 .Uuid(string)
3 .IncludeCustom(bool)
required
Uuid required#
Type: string
Unique user identifier (UUID). If not supplied, the current user's UUID is used.
IncludeCustom#
Type: bool
Whether to include the Custom object in the response.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Get Metadata for UUID set in the pubnub instance
15PNResult<PNGetUuidMetadataResult> getUuidSetMetadataResponse = await pubnub.GetUuidMetadata()
show all 25 lines

Response​

1{
2 "Uuid": "uuid-1",
3 "Name": "John Doe",
4 "Email": "jack@twitter.com",
5 "ExternalId": null,
6 "ProfileUrl": null,
7 "Custom": null,
8 "Updated": "2020-06-17T16:28:14.060718Z"
9}

Set user metadata​

Unsupported partial updates of custom metadata

The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:

  1. Get the existing metadata and store it locally.
  2. Append the new custom metadata to the existing one.
  3. Set the entire updated custom object.

Set metadata for a UUID in the database, optionally including the custom data object for each.

Method(s)​

To Set UUID Metadata you can use the following method(s) in the C# SDK:

1pubnub.SetUuidMetadata()
2 .Uuid(string)
3 .Name(string)
4 .Email(string)
5 .ExternalId(string)
6 .ProfileUrl(string)
7 .Custom(Dictionary<string, object>)
8 .IncludeCustom(bool)
9 .IfMatchesEtag(string)
required
Uuid required#
Type: string
Unique user identifier (UUID). If not supplied, the current user's UUID is used.
Name required#
Type: string
Display name for the user.
Email#
Type: string
The user's email address.
ExternalId#
Type: string
User's identifier in an external system.
ProfileUrl#
Type: string
The URL of the user's profile picture.
Custom#
Type: Dictionary<string, object>
Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported.
IncludeCustom#
Type: bool
Whether to include the Custom object in the response.
IfMatchesEtag#
Type: String
Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412.
API limits

To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Set Metadata for UUID set in the pubnub instance
15PNResult<PNSetUuidMetadataResult> setUuidMetadataResponse = await pubnub.SetUuidMetadata()
show all 21 lines

Response​

1{
2 "Uuid": "uuid-1",
3 "Name": "John Doe",
4 "Email": "jack@twitter.com",
5 "ExternalId": null,
6 "ProfileUrl": null,
7 "Custom": null,
8 "Updated": "2020-06-17T16:28:14.060718Z"
9}

Remove user metadata​

Removes the metadata from a specified UUID.

Method(s)​

To Remove UUID Metadata you can use the following method(s) in the C# SDK:

1pubnub.RemoveUuidMetadata()
2 .Uuid(string)
required
Uuid required#
Type: string
Unique user identifier (UUID). If not supplied, the current user's UUID is used.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Remove Metadata for UUID set in the pubnub instance
15PNResult<PNRemoveUuidMetadataResult> removeUuidMetadataResponse = await pubnub.RemoveUuidMetadata()
show all 18 lines

Response​

1{}

Channel​

Get metadata for all channels​

Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

Required keyset configuration
To get all channel and user metadata, you must uncheck the Disallow Get All Channel Metadata and Disallow Get All User Metadata checkboxes in the App Context section of your keyset configuration in the Admin Portal.

Method(s)​

To Get All Channel Metadata you can use the following method(s) in the C# SDK:

1pubnub.GetAllChannelMetadata()
2 .IncludeCustom(bool)
3 .IncludeCount(bool)
4 .Page(PNPageObject)
5 .Sort(List<string>)
6 .Filter(string)
IncludeCustom#
Type: bool
Whether to include the Custom object in the response.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).
Filter#
Type: string
Filter expression. Only matching objects are returned. See filtering.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14PNResult<PNGetAllChannelMetadataResult> getAllChannelMetadataResponse = await pubnub.GetAllChannelMetadata()
15 .IncludeCount(true)
show all 20 lines

Response​

1{
2 "Channels": [
3 {
4 "Channel": "my-channel",
5 "Name": "My channel",
6 "Description": "A channel that is mine",
7 "Custom": null,
8 "Updated": "2020-06-17T16:52:19.562469Z"
9 },
10 {
11 "Channel": "main",
12 "Name": "Main channel",
13 "Description": "The main channel",
14 "Custom": {
15 "public": true,
show all 26 lines

Get channel metadata​

Returns metadata for the specified Channel, optionally including the custom data object for each.

Method(s)​

To Get Channel Metadata you can use the following method(s) in the C# SDK:

1pubnub.GetChannelMetadata()
2 .Channel(string)
3 .IncludeCustom(bool)
required
Channel required#
Type: string
Channel name.
IncludeCustom#
Type: bool
Whether to include the Custom object in the response.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Get Metadata for a specific channel
15PNResult<PNGetChannelMetadataResult> getChannelMetadataResponse = await pubnub.GetChannelMetadata()
show all 21 lines

Response​

1{
2 "Channel": "my-channel",
3 "Name": "My channel",
4 "Description": "A channel that is mine",
5 "Custom": null,
6 "Updated": "2020-06-17T16:52:19.562469Z"
7}

Set channel metadata​

Unsupported partial updates of custom metadata

The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:

  1. Get the existing metadata and store it locally.
  2. Append the new custom metadata to the existing one.
  3. Set the entire updated custom object.

Set metadata for a Channel in the database, optionally including the custom data object for each.

Method(s)​

To Set Channel Metadata you can use the following method(s) in the C# SDK:

1pubnub.SetChannelMetadata()
2 .Channel(string)
3 .Name(string)
4 .Description(string)
5 .Custom(Dictionary<string, object>)
6 .IncludeCustom(bool)
7 .IfMatchesEtag(string)
required
Channel required#
Type: string
Channel name.
Name#
Type: string
Channel name.
Description#
Type: string
Channel description.
Custom#
Type: Dictionary<string, object>
Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported.
IncludeCustom#
Type: bool
Whether to include the Custom object in the response.
IfMatchesEtag#
Type: String
Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412.
API limits

To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Set Metadata for a specific channel
15PNResult<PNSetChannelMetadataResult> setChannelMetadataResponse = await pubnub.SetChannelMetadata()
show all 24 lines

Response​

1{
2 "Channel": "my-channel",
3 "Name": "John Doe",
4 "Description": "sample description",
5 "Custom": {
6 "color": "blue"
7 },
8 "Updated": "2020-06-17T16:52:19.562469Z"
9}

Other examples​

Iteratively update existing metadata​
1using PubnubApi;
2
3PNConfiguration config = new PNConfiguration(new UserId("example"))
4{
5 PublishKey = "demo",
6 SubscribeKey = "demo",
7};
8Pubnub pubnub = new Pubnub(config);
9string channel = "team.red";
10string name = "Red Team";
11string description = "The channel for Red team.";
12var customField = new Dictionary<string, object>()
13{
14 { "visible", "team" },
15};
show all 52 lines

Remove channel metadata​

Removes the metadata from a specified channel.

Method(s)​

To Remove Channel Metadata you can use the following method(s) in the C# SDK:

1pubnub.RemoveChannelMetadata()
2 .Channel(string)
required
Channel required#
Type: string
Channel name.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Delete Metadata for a specific channel
15PNResult<PNRemoveChannelMetadataResult> removeChannelMetadataResponse = await pubnub.RemoveChannelMetadata()
show all 20 lines

Response​

1{}

Channel memberships​

Get channel memberships​

This method returns a list of channel memberships for a user. This method doesn't return subscriptions.

Method(s)​

To Get Memberships you can use the following method(s) in the C# SDK:

1pubnub.GetMemberships()
2 .Uuid(string)
3 .Include(PNMembershipField[])
4 .IncludeCount(bool)
5 .Page(PNPageObject)
required
Uuid required#
Type: string
Unique user identifier (UUID). If not supplied, the current user's UUID is used.
Include#
Type: PNMembershipField[]
Whether to include additional fields.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14PNResult<PNMembershipsResult> getMembershipsResponse = await pubnub.GetMemberships()
15 .Uuid("my-uuid")
show all 22 lines

Response​

1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 lines

Set channel memberships​

Set channel memberships for a UUID.

Method(s)​

To Set Memberships you can use the following method(s) in the C# SDK:

1pubnub.SetMemberships()
2 .Uuid(string)
3 .Channels(List<PNMembership>)
4 .Include(PNMembershipField[])
5 .IncludeCount(bool)
6 .Page(PNPageObject)
7 .Sort(List<string>)
8 .Filter(string)
9 .Limit(int)
required
Uuid required#
Type: string
Unique user identifier (UUID). If not supplied, the current user's UUID is used.
Channels required#
Type: List<PNMembership>
Channels to add to the membership. Accepts channel names (strings) or objects (with optional custom data).
Include#
Type: PNMembershipField[]
Whether to include additional fields.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).
Filter#
Type: string
Filter expression. Only matching objects are returned. See filtering.
Limit#
Type: int
Number of objects to return. Default/Max: 100.
API limits

To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.

PNMembership​

required
Channel required#
Type: string
The name of the channel associated with this membership.
Custom#
Type: Dictionary<string, object>
A dictionary that stores custom metadata related to the membership, allowing for additional context or information. Values can be strings, numbers, or booleans.
Status#
Type: string
The status of the membership, for example: "active" or "inactive"
Type#
Type: string
The type of membership for categorization purposes.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14List<PNMembership> setMembershipChannelMetadataIdList =
15[
show all 28 lines

Response​

1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 lines

Remove channel memberships​

Remove channel memberships for a UUID.

Method(s)​

To Remove Memberships you can use the following method(s) in the C# SDK:

1pubnub.RemoveMemberships()
2 .Uuid(string)
3 .Channels(List<string>)
4 .Include(PNMembershipField[])
5 .IncludeCount(bool)
6 .Page(PNPageObject)
7 .Sort(List<string>)
8 .Filter(string)
9 .Limit(int)
required
Uuid#
Type: String
Unique user identifier (UUID). If not supplied, the current user's UUID is used.
Channels required#
Type: List<string>
Channels to remove from membership.
Include#
Type: PNMembershipField[]
Whether to include additional fields.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).
Filter#
Type: string
Filter expression. Only matching objects are returned. See filtering.
Limit#
Type: int
Number of objects to return. Default/Max: 100.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14List<string> removeMembershipList =
15[
show all 28 lines

Response​

1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 lines

Manage channel memberships​

Set and remove channel memberships for a user.

Method(s)​

To Manage Memberships you can use the following method(s) in the C# SDK:

1pubnub.ManageMemberships()
2 .Uuid(string)
3 .Set(List<PNMembership>)
4 .Remove(List<string>)
5 .Include(PNMembershipField[])
6 .IncludeCount(bool)
7 .Page(PNPageObject)
8 .Sort(List<string>)
required
Uuid required#
Type: string
Unique user identifier (UUID). If not supplied, the current user's UUID is used.
Set#
Type: List<PNMembership>
Set channel memberships for the user.
Remove#
Type: List<string>
Remove channel memberships for the user.
Include#
Type: PNMembershipField[]
Whether to include additional fields.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14List<PNMembership> setMembrshipList =
15[
show all 37 lines

Response​

1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 lines

Channel members​

Get channel members​

This method returns a list of members in a channel. The list includes user metadata for members that have additional metadata stored in the database.

Method(s)​

To Get Channel Members you can use the following method(s) in the C# SDK:

1pubnub.GetChannelMembers()
2 .Channel(string)
3 .Include(PNChannelMemberField[])
4 .IncludeCount(bool)
5 .Page(PNPageObject)
6 .Sort(List<string>)
7 .Filter(string)
8 .Limit(int)
required
Channel required#
Type: string
Channel name.
Include#
Type: PNChannelMemberField[]
Whether to include additional fields.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).
Filter#
Type: string
Filter expression. Only matching objects are returned. See filtering.
Limit#
Type: int
Number of objects to return. Default/Max: 100.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Get Members (uuids) for a specific channel
15PNResult<PNChannelMembersResult> getChannelMembersResponse = await pubnub.GetChannelMembers()
show all 22 lines

Response​

1{
2 "ChannelMembers": [
3 {
4 "UuidMetadata": {
5 "Uuid": "uuid-1",
6 "Name": "John Doe",
7 "Email": "jack@twitter.com",
8 "ExternalId": "",
9 "ProfileUrl": "",
10 "Custom": null,
11 "Updated": "2019-02-20T23:11:20.89375"
12 },
13 "Custom": {
14 "role": "admin"
15 },
show all 39 lines

Set channel members​

This method sets members in a channel.

Method(s)​

To Set Channel Members you can use the following method(s) in the C# SDK:

1pubnub.SetChannelMembers().Channel(string).Uuids(List<PNChannelMember>).Include(PNChannelMemberField[]).Page(PNPageObject).Sort(List<string>).Filter(string).Limit(int)
required
Channel required#
Type: String
Channel name.
Uuids required#
Type: List<PNChannelMember>
Members to add to the channel. Accepts UUIDs (strings) or objects (with optional custom data).
Include#
Type: PNChannelMemberField[]
Whether to include additional fields.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).
Filter#
Type: string
Filter expression. Only matching objects are returned. See filtering.
Limit#
Type: int
Number of objects to return. Default/Max: 100.
API limits

To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Add Members (UUID) for a specific channel
15List<PNChannelMember> setMemberChannelList =
show all 29 lines

Response​

1{
2 "ChannelMembers": [
3 {
4 "UuidMetadata": {
5 "Uuid": "uuid-1",
6 "Name": "John Doe",
7 "Email": "jack@twitter.com",
8 "ExternalId": "",
9 "ProfileUrl": "",
10 "Custom": null,
11 "Updated": "2019-02-20T23:11:20.89375"
12 },
13 "Custom": {
14 "role": "admin"
15 },
show all 39 lines

Remove channel members​

Remove members from a Channel.

Method(s)​

To Remove Channel Members you can use the following method(s) in the C# SDK:

1pubnub.RemoveChannelMembers()
2 .Channel(string)
3 .Remove( List)
4 .Include(PNChannelMembersInclude[])
5 .Limit(int)
6 .Count(bool)
7 .Start(string)
8 .End(string)
9 .Sort(List)
10 .Async()
required
Channel required#
Type: string
Channel name.
Uuids required#
Type: List<string>
Members to remove from the channel.
Include#
Type: PNChannelMemberField[]
Whether to include additional fields.
IncludeCount#
Type: bool
Whether to include the total count in the paginated response. Default is false.
Page#
Type: PNPageObject
Cursor-based pagination.
Sort#
Type: List<string>
Sort by id, name, updated with asc/desc (for example, {name: 'asc'}).
Filter#
Type: string
Filter expression. Only matching objects are returned. See filtering.
Limit#
Type: int
Number of objects to return. Default/Max: 100.

Sample code​

1using PubnubApi;
2
3// Configuration
4PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
5{
6 SubscribeKey = "demo",
7 PublishKey = "demo",
8 Secure = true
9};
10
11// Initialize PubNub
12Pubnub pubnub = new Pubnub(pnConfiguration);
13
14// Remove Members (UUID) for a specific channel
15List<string> removeChannelMemberList =
show all 29 lines

Response​

1{
2 "ChannelMembers": [
3 {
4 "UuidMetadata": {
5 "Uuid": "uuid-1",
6 "Name": "John Doe",
7 "Email": "jack@twitter.com",
8 "ExternalId": "",
9 "ProfileUrl": "",
10 "Custom": null,
11 "Updated": "2019-02-20T23:11:20.89375"
12 },
13 "Custom": {
14 "role": "admin"
15 },
show all 39 lines

Was this page useful?

Last updated on