C#C# V4 Objects API Reference for Realtime Apps

This page describes the new Objects v2. To upgrade from Objects v1, refer to the migration guide.
 

These docs are for PubNub 4.0 for C# which is our latest and greatest! For the docs of the 3.x versions of the SDK, please check the links: C#, Windows 8, Windows 8.1, ASP.Net, Windows Phone 8, Windows Phone 8.1, Xamarin.iOS, Xamarin.Android, Xamarin.Mac and C# PCL.

If you have questions about the PubNub for C# SDK, please contact us at support@pubnub.com.

Objects provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use Objects to easily store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.

PubNub also triggers events when object data is set or removed from the database. Clients can receive these events in realtime and update their front-end application accordingly.

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

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

  1. ParameterTypeRequiredDescription
    IncludeCustomboolOptionalWhether to fetch Custom fields or not.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
    FilterstringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    LimitintOptionalNumber of objects to return in response. Default is 100, which is also the maximum value.
PNResult<PNGetAllUuidMetadataResult> getAllUuidMetadataResponse = await pubnub.GetAllUuidMetadata()
    .IncludeCustom(true)
    .IncludeCount(true)
    .ExecuteAsync();

PNGetAllUuidMetadataResult getAllUuidMetadataResult = getAllUuidMetadataResponse.Result;
PNStatus status = getAllUuidMetadataResponse.Status;
{
    "Uuids": [
        {
            "Uuid": "uuid-1",
            "Name": "John Doe",
            "Email": "jack@twitter.com",
            "ExternalId": null,
            "ProfileUrl": null,
            "Custom": null,
            "Updated": "2020-06-17T16:28:14.060718Z"
        },
        {
            "Uuid": "uuid-2",
            "Name": "Bob Cat",
            "Email": "bobc@example.com",
            "ExternalId": null,
            "ProfileUrl": null,
            "Custom": {
                "phone": "999-999-9999"
            },
            "Updated": "2020-06-17T16:42:22.906768Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MTI",
        "Prev": ""
    }
}

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

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

  1. ParameterTypeRequiredDescription
    UuidstringYesUnique user identifier. If not supplied then current user’s Uuid is used.
    IncludeCustomboolOptionalWhether to fetch Custom fields or not.
// Get Metadata for UUID set in the pubnub instance
PNResult<PNGetUuidMetadataResult> getUuidMetadataResponse = await pubnub.GetUuidMetadata()
    .ExecuteAsync();
PNGetUuidMetadataResult getUuidMetadataResult = getUuidMetadataResponse.Result;
PNStatus status = getUuidMetadataResponse.Status;



// Get Metadata for a specific UUID
PNResult<PNGetUuidMetadataResult> getUuidMetadataResponse = await pubnub.GetUuidMetadata()
    .Uuid("my-uuid")
    .ExecuteAsync();
PNGetUuidMetadataResult getUuidMetadataResult = getUuidMetadataResponse.Result;
PNStatus status = getUuidMetadataResponse.Status;
{
    "Uuid": "uuid-1",
    "Name": "John Doe",
    "Email": "jack@twitter.com",
    "ExternalId": null,
    "ProfileUrl": null,
    "Custom": null,
    "Updated": "2020-06-17T16:28:14.060718Z"
}

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

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

  1. ParameterTypeRequiredDescription
    UuidstringYesUnique user identifier. If not supplied then current user’s Uuid is used.
    NamestringYesDisplay name for the user.
    Maximum 200 characters.
    EmailstringOptionalThe user's email address.
    Maximum 80 characters.
    ExternalIdstringOptionalUser's identifier in an external system
    ProfileUrlstringOptionalThe URL of the user's profile picture
    CustomDictionary<string, object>OptionalJSON object of key-value pairs with supported data types.
    IncludeCustomboolOptionalWhether to fetch Custom fields or not.
// Set Metadata for UUID set in the pubnub instance
PNResult<PNSetUuidMetadataResult> setUuidMetadataResponse = await pubnub.SetUuidMetadata()
    .Uuid(config.Uuid)
    .Name("John Doe")
    .Email("john.doe@user.com")
    .ExecuteAsync();
PNSetUuidMetadataResult setUuidMetadataResult = setUuidMetadataResponse.Result;
PNStatus status = setUuidMetadataResponse.Status;
{
    "Uuid": "uuid-1",
    "Name": "John Doe",
    "Email": "jack@twitter.com",
    "ExternalId": null,
    "ProfileUrl": null,
    "Custom": null,
    "Updated": "2020-06-17T16:28:14.060718Z"
}

Removes the metadata from a specified UUID.

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

  1. ParameterTypeRequiredDescription
    UuidstringOptionalUnique user identifier. If not supplied then current user’s Uuid is used.
// Remove Metadata for UUID set in the pubnub instance
PNResult<PNRemoveUuidMetadataResult> removeUuidMetadataResponse = await pubnub.RemoveUuidMetadata()
    .ExecuteAsync();
PNRemoveUuidMetadataResult removeUuidMetadataResult = removeUuidMetadataResponse.Result;
PNStatus status = removeUuidMetadataResponse.Status;
{}

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

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

  1. ParameterTypeRequiredDescription
    IncludeCustomboolOptionalWhether to fetch Custom fields or not.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
    FilterstringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
PNResult<PNGetAllChannelMetadataResult> getAllChannelMetadataResponse = await pubnub.GetAllChannelMetadata()
    .IncludeCount(true)
    .IncludeCustom(true)
    .ExecuteAsync();

PNGetAllChannelMetadataResult getAllChannelMetadataResult = getAllChannelMetadataResponse.Result;
PNStatus status2 = getAllChannelMetadataResponse.Status;
{
    "Channels": [
        {
            "Channel": "my-channel",
            "Name": "My channel",
            "Description": "A channel that is mine",
            "Custom": null,
            "Updated": "2020-06-17T16:52:19.562469Z"
        },
        {
            "Channel": "main",
            "Name": "Main channel",
            "Description": "The main channel",
            "Custom": {
                "public": true,
                "motd": "Always check your spelling!"
            },
            "Updated": "2020-06-17T16:52:19.562469Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MTE",
        "Prev": ""
    }
}

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

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

  1. ParameterTypeRequiredDescription
    ChannelstringYesChannel name.
    IncludeCustomboolOptionalWhether to fetch Custom fields or not.
// Get Metadata for a specific channel
PNResult<PNGetChannelMetadataResult> getChannelMetadataResponse = await pubnub.GetChannelMetadata()
    .Channel("my-channel")
    .IncludeCustom(true)
    .ExecuteAsync();

PNGetChannelMetadataResult getChannelMetadataResult = getChannelMetadataResponse.Result;
PNStatus status = getChannelMetadataResponse.Status;
{
    "Channel": "my-channel",
    "Name": "My channel",
    "Description": "A channel that is mine",
    "Custom": null,
    "Updated": "2020-06-17T16:52:19.562469Z"
}

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

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

  1. ParameterTypeRequiredDescription
    ChannelstringYesChannel name.
    NamestringOptionalName of a channel.
    DescriptionstringOptionalDescription of a channel.
    CustomDictionary<string, object>OptionalInclude respective additional fields in the response.
    IncludeCustomboolOptionalWhether to fetch custom fields or not.
// Set Metadata for a specific channel
PNResult<PNSetChannelMetadataResult> setChannelMetadataResponse = await pubnub.SetChannelMetadata()
    .Channel("my-channel")
    .Name("John Doe")
    .Description("sample description")
    .Custom(new Dictionary<string, object>() { { "color", "blue" } })
    .IncludeCustom(true)
    .ExecuteAsync();

PNSetChannelMetadataResult setChannelMetadataResult = setChannelMetadataResponse.Result;
PNStatus status = setChannelMetadataResponse.Status;
{
    "Channel": "my-channel",
    "Name": "John Doe",
    "Description": "sample description",
    "Custom": {
        "color": "blue"
    },
    "Updated": "2020-06-17T16:52:19.562469Z"
}

Removes the metadata from a specified channel.

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

  1. ParameterTypeRequiredDescription
    ChannelstringYesChannel name.
// Delete Metadata for a specific channel
PNResult<PNRemoveChannelMetadataResult> removeChannelMetadataResponse = await pubnub.RemoveChannelMetadata()
    .Channel("mychannel")
    .ExecuteAsync();

PNRemoveChannelMetadataResult removeChannelMetadataResult = removeChannelMetadataResponse.Result;
PNStatus status = removeChannelMetadataResponse.Status;
{}

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

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

  1. ParameterTypeRequiredDescription
    UuidstringOptionalUnique user identifier. If not supplied then current user’s Uuid is used.
    IncludePNMembershipField[]OptionalInclude respective additional fields in the response.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
PNResult<PNGetMembershipsResult> getMembershipsResponse = await pubnub.GetMemberships()
    .Uuid("my-uuid")
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .Page(new PNPageObject() { Next = "", Prev = "" })
    .ExecuteAsync();

PNGetMembershipsResult getMembeshipsResult = getMembershipsResponse.Result;
PNStatus status = getMembershipsResponse.Status;
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}

Set channel memberships for a UUID.

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

  1. ParameterTypeRequiredDescription
    UuidstringOptionalUnique user identifier. If not supplied then current user’s Uuid is used.
    ChannelsList<PNMembership>YesList of Channels to add to membership. List can contain strings (channel-name only) or objects (which can include custom data).
    IncludePNMembershipField[]OptionalInclude respective additional fields in the response.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
    FilterstringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    LimitintOptionalNumber of objects to return in response. Default is 100, which is also the maximum value.
List<PNMembership> setMembershipChannelMetadataIdList = new List<PNMembership>();
if (!string.IsNullOrEmpty(seMembershipChannelMetaId))
{
    setMembershipChannelMetadataIdList.Add(new PNMembership() { Channel = "my-channel", Custom = new Dictionary<string, object>() { { "item", "book" } } });
}

PNResult<PNMembershipsResult> setMembershipsResponse = await pubnub.SetMemberships()
    .Uuid("my-uuid")
    .Channels(setMembershipChannelMetadataIdList)
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNMembershipsResult setMembershipsResult = setMembershipsResponse.Result;
PNStatus status = setMembershipsResponse.Status;
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}

Remove channel memberships for a UUID.

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

  1. ParameterTypeRequiredDescription
    UuidStringOptionalUnique user identifier. If not supplied then current user’s Uuid is used.
    ChannelsList<string>YesChannels to remove from membership.
    IncludePNMembershipField[]OptionalInclude respective additional fields in the response.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
    FilterstringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    LimitintOptionalNumber of objects to return in response. Default is 100, which is also the maximum value.
List<string> removeMembershipList = new List<string>();
if (!string.IsNullOrEmpty(removeMembershipChannelMetaId))
{
    removeMembershipList.Add("my-channel");
    removeMembershipList.Add("your-channel");
}

PNResult<PNMembershipsResult> removeMembershipsResponse = await pubnub.RemoveMemberships()
    .Uuid("uuid")
    .Channels(removeMembershipList)
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNMembershipsResult removeMembershipsResult = removeMembershipsResponse.Result;
PNStatus status2 = removeMembershipsResponse.Status;
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}

The method Set and Remove channel memberships for a user.

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

  1. ParameterTypeRequiredDescription
    UuidstringOptionalUnique user identifier. If not supplied then current user’s Uuid is used.
    SetList<PNMembership>OptionalSet channel memberships for the user.
    RemoveList<string>OptionalRemove channel memberships for the user.
    IncludePNMembershipField[]OptionalInclude respective additional fields in the response.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
List<PNMembership> setMembrshipList = new List<PNMembership>();
setMembrshipList.Add(new PNMembership() { Channel = "ch1", Custom = new Dictionary<string, object>() { { "say","hello" } } });
setMembrshipList.Add(new PNMembership() { Channel = "ch2", Custom = new Dictionary<string, object>() { { "say", "world" } } });
setMembrshipList.Add(new PNMembership() { Channel = "ch3", Custom = new Dictionary<string, object>() { { "say", "bye" } } });

List<string> removeMembrshipList = new List<string>();
removeMembrshipList.Add("ch4");
                        
PNResult<PNManageMembershipsResult> manageMmbrshipsResponse = await pubnub.ManageMemberships()
    .Uuid("my-uuid")
    .Set(setMembrshipList)
    .Remove(removeMembrshipList)
    .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM })
    .IncludeCount(true)
    .Page(new PNPageObject() { Next = "", Prev = "" })
    .Sort(new List<string>() { "channel.id:asc" })
    .ExecuteAsync();

PNManageMembershipsResult manageMmbrshipsResult = manageMmbrshipsResponse.Result;
PNStatus status = manageMmbrshipsResponse.Status;
{
    "Memberships": [
        {
            "ChannelMetadata": {
                "Channel": "my-channel",
                "Name": "My channel",
                "Description": "A channel that is mine",
                "Custom": null,
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "starred": false
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "ChannelMetadata": {
                "Channel": "main",
                "Name": "Main channel",
                "Description": "The main channel",
                "Custom": {
                    "public": true,
                    "motd": "Always check your spelling!"
                },
                "Updated": "2020-06-17T16:55:44.632042Z"
            },
            "Custom": {
                "item": "book"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}

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

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

  1. ParameterTypeRequiredDescription
    ChannelstringYesChannel name.
    IncludePNChannelMemberField[]OptionalInclude respective additional fields in the response.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
    FilterstringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    LimitintOptionalNumber of objects to return in response. Default is 100, which is also the maximum value.
// Get Members (uuids) for a specific channel
PNResult<PNChannelMembersResult> getChannelMembersResponse = await pubnub.GetChannelMembers()
    .Channel("my-channel")
    .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNChannelMembersResult getChannelMembersResult = getChannelMembersResponse.Result;
PNStatus status2 = getChannelMembersResponse.Status;
{
    "ChannelMembers": [
        {
            "UuidMetadata": {
                "Uuid": "uuid-1",
                "Name": "John Doe",
                "Email": "jack@twitter.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": null,
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": {
                "role": "admin"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "UuidMetadata": {
                "Uuid": "uuid-2",
                "Name": "Bob Cat",
                "Email": "bobc@example.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": {
                    "phone": "999-999-9999"
                },
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": null,
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}

This method sets members in a channel.

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

  1. ParameterTypeRequiredDescription
    ChannelStringYesChannel name.
    UuidsList<PNChannelMember>YesList of members to add to the channel. List can contain strings (Uuids only) or objects (which can include custom data).
    IncludePNChannelMemberField[]OptionalInclude respective additional fields in the response.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
    FilterstringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    LimitintOptionalNumber of objects to return in response. Default is 100, which is also the maximum value.
// Add Members (UUID) for a specific channel
List<PNChannelMember> setMemberChannelList = new List<PNChannelMember>();
if (!string.IsNullOrEmpty(setMemberChUuid))
{
    setMemberChannelList.Add(new PNChannelMember() { Uuid = "my-uuid", Custom = new Dictionary<string, object>() { { "planet", "earth" } } });
}
PNResult<PNChannelMembersResult> setChannelMembersResponse = await pubnub.SetChannelMembers()
    .Channel(setmemberChMetadataId)
    .Uuids(setMemberChannelList)
    .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNChannelMembersResult setChannelMembersResult = setChannelMembersResponse.Result;
PNStatus status2 = setChannelMembersResponse.Status;
{
    "ChannelMembers": [
        {
            "UuidMetadata": {
                "Uuid": "uuid-1",
                "Name": "John Doe",
                "Email": "jack@twitter.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": null,
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": {
                "role": "admin"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "UuidMetadata": {
                "Uuid": "uuid-2",
                "Name": "Bob Cat",
                "Email": "bobc@example.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": {
                    "phone": "999-999-9999"
                },
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": null,
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}

Remove members from a Channel.

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

  1. ParameterTypeRequiredDescription
    ChannelstringYesChannel name.
    UuidsList<string>YesMembers to remove from channel.
    IncludePNChannelMemberField[]OptionalInclude respective additional fields in the response.
    IncludeCountboolOptionalRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
    PagePNPageObjectOptionalUse for pagination.
    SortList<string>OptionalList of properties to sort by.

    Use asc or desc to specify sort direction.
    FilterstringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
    LimitintOptionalNumber of objects to return in response. Default is 100, which is also the maximum value.
// Remove Members (UUID) for a specific channel
List<string> removeChannelMemberList = new List<string>();
removeChannelMemberList.Add("my-uuid");
removeChannelMemberList.Add("your-uuid");

PNResult<PNChannelMembersResult> removeChannelMembersResponse = await pubnub.RemoveChannelMembers()
    .Channel("my-channel")
    .Uuids(removeChannelMemberList)
    .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM })
    .IncludeCount(true)
    .ExecuteAsync();

PNChannelMembersResult removeChannelMembersResult = removeChannelMembersResponse.Result;
PNStatus status = removeChannelMembersResponse.Status;
{
    "ChannelMembers": [
        {
            "UuidMetadata": {
                "Uuid": "uuid-1",
                "Name": "John Doe",
                "Email": "jack@twitter.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": null,
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": {
                "role": "admin"
            },
            "Updated": "2020-06-17T17:05:25.987964Z"
        },
        {
            "UuidMetadata": {
                "Uuid": "uuid-2",
                "Name": "Bob Cat",
                "Email": "bobc@example.com",
                "ExternalId": "",
                "ProfileUrl": "",
                "Custom": {
                    "phone": "999-999-9999"
                },
                "Updated": "2019-02-20T23:11:20.89375"
            },
            "Custom": null,
            "Updated": "2020-06-17T17:05:25.987964Z"
        }
    ],
    "TotalCount": 2,
    "Page": {
        "Next": "MQ",
        "Prev": ""
    }
}

The filtering language for Objects is similar to the stream filtering language.

Note the following:

  • Date/time properties, such as updated, must be compared to valid date/time strings formatted according to ISO 8601.
  • Custom properties must have the same type as the value used in the expression; it is an error to compare a custom property of one type to a value of another type.
  • Objects that do not have the referenced custom property at all are excluded regardless of the operator or value used in the expression. The null value can be used to filter out objects that do or do not have the referenced custom property.
  • The LIKE operator supports wildcards denoted by the * character. A wildcard matches any sequence of arbitrary Unicode characters, including the empty sequence. The literal asterisk is matched when escaped using the backslash (\) character.
  • Values used with LIKE must be properly encoded just like any other string value. Thus, in order to escape an asterisk, the raw value must contain \\*.
  • The entire expression must be properly URL-encoded when used in the query string.

<expression>           ::= <and_expression> ( "||" <and_expression> )*
<and_expression>       ::= <binary_condition> ( "&&" <binary_condition> )*
<binary_condition>     ::= "!" <binary_condition> | "(" <expression> ")" | <relational_condition>
<relational_condition> ::= <property_path> <relational_operator> <value>
<property_path>        ::= <property_name> ( "." <property_name> )*
<property_name>        ::= <identifier> | "[" <string> "]"
<value>                ::= <string> | <number> | "true" | "false" | "null"

Tokens

<identifier>           ::=  <letter> | "$" | "_" ( <letter> | "$" | "_" | <digit> )*
<relational_operator>  ::= "==" | "!=" | "<=" | ">=" | "<" | ">" | "LIKE"
<string>               ::= <double_quote> ( "\" <double_quote> | "\" <special_char>
                            | "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
                            | <unicode_char> - <double_quote> - "\" )* <double_quote>
                            | "'" ( "\" "'" | "\" <special_char>
                            | "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
                            | <unicode_char> - "'" - "\" )* "'"
<number>               ::= ( "+" | "-" )? ( <digit> )* ( "." )? <digit> ( <digit> )* 
                            ( "e" | "E" ( "+" | "-" )? <digit> ( <digit> )* )?
<letter>               ::= Unicode Letter (category; any kind of letter from any language)
<digit>                ::= "0" .. "9"
<hex_digit>            ::= <digit> | "A" .. "F"
<double_quote>         ::= the " character
<unicode_char>         ::= any character in the Unicode range from U+0020 to U+10FFFF inclusive
<special_char>         ::= "\" | "/" | "b" | "f" | "n" | "r" | "t"

The following simple expression returns results whose custom property named public is equal to Boolean true.


custom.public == true

The following date/time comparison returns results that were modified on or after August 31st, 2019 (UTC):


updated >= "2019-08-31T00:00:00Z"

The following compound expression returns results that don't have a description, but do have a non-empty custom label or description property:


description == null && (custom.label != "" || custom.description != "")

The following wildcard expression returns results whose name starts with the letter X:


name LIKE 'X*'

The following escaped wildcard expression returns results whose name contains an asterisk:


name LIKE '*\\**'