Metadata API for PubNub Dart SDK

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

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.

User

Get Metadata for All Users

Description

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

Method(s)

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

pubnub.objects.getAllUUIDMetadata(
{bool? includeCustomFields,
int? limit,
String? start,
String? end,
bool? includeCount,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
ParameterTypeRequiredDefaultDescription
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
limitintOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCountboolOptionaltrueRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

var result = await pubnub.objects
.getAllUUIDMetadata(includeCustomFields: true, limit: 20);

Response

{
"status": 200,
"data": [
{
"id": "uuid-1",
"name": "John Doe",
"externalId": null,
"profileUrl": null,
"email": "johndoe@pubnub.com",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
},
{
"id": "uuid-2",
show all 27 lines

Get User Metadata

Description

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 Dart SDK:

pubnub.objects.getUUIDMetadata(
{String? uuid,
Keyset? keyset,
String? using,
bool? includeCustomFields}
)
ParameterTypeRequiredDefaultDescription
uuidStringOptionaldefaultKeyset UUIDThe UUID to get the metadata for.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.

Basic Usage

var result = await pubnub.objects.getUUIDMetadata();

Response

{
"status": 200,
"data": {
"id": "uuid-1",
"name": "John Doe",
"externalId": null,
"profileUrl": null,
"email": "johndoe@pubnub.com",
"updated": "2019-02-20T23:11:20.893755",
"eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
}
}

Set User Metadata

Description

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 Dart SDK:

pubnub.objects.setUUIDMetadata(
UuidMetadataInput uuidMetadataInput,
{String? uuid,
bool? includeCustomFields,
Keyset? keyset,
String? using}
)

class UuidMetadataInput {
String? name;
String? email;
dynamic? custom;
String? externalId;
String? profileUrl;
}
ParameterTypeRequiredDefaultDescription
uuidMetadataInputUuidMetadataInputYesUUID metadata details. Available options include name,email,custom,externalId, and profileUrl. Objects filtering language doesn’t support filtering by custom properties.
uuidStringOptionaldefaultKeyset UUIDUUID to set the metadata to.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

var uuidMetadataInput = UuidMetadataInput(
name: 'foo',
email: 'foo@example.domain',
profileUrl: 'http://sample.com');
var result = await pubnub.objects.setUUIDMetadata(uuidMetadataInput);

Response

{
"status": 200,
"data": {
"id": "uuid-1",
"name": "John Doe",
"externalId": null,
"profileUrl": null,
"email": "johndoe@pubnub.com",
"updated": "2019-02-20T23:11:20.893755",
"eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
}
}

Remove User Metadata

Description

Removes the metadata from a specified UUID.

Method(s)

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

pubnub.objects.removeUUIDMetadata(
{String? uuid,
Keyset? keyset,
String? using}
)
ParameterTypeRequiredDescription
uuidStringOptionalUnique UUID Metadata identifier.
If not supplied, then UUID from configuration will be used.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

var result = await pubnub.objects.removeUUIDMetadata();

Response

The removeUUIDMetadata() returns RemoveUuidMetadataResult which does not have actionable data. In case of an error, an exception with error details is thrown.

Channel

Get Metadata for All Channels

Description

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

Method(s)

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

pubnub.objects.getAllChannelMetadata(
{int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeCount,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
ParameterTypeRequiredDefaultDescription
limitintOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeCountboolOptionaltrueRequest IncludeCount to be included in paginated response. By default, IncludeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

var result = await pubnub.objects.getAllChannelMetadata();

Response

{
"status": 200,
"data": [
{
"id": "my-channel",
"name": "My channel",
"description": "A channel that is mine",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
},
{
"id": "main",
"name": "Main channel",
"description": "The main channel",
show all 27 lines

Get Channel Metadata

Description

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 Dart SDK:

pubnub.objects.getChannelMetadata(
String channelId,
{Keyset? keyset,
String? using,
bool? includeCustomFields}
)
ParameterTypeRequiredDefaultDescription
channelIdStringYesChannel name.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.

Basic Usage

var channelMetadata = await pubnub.objects.getChannelMetadata('my_channel');

Response

{
"status": 200,
"data": {
"id": "my-channel",
"name": "My channel",
"description": "A channel that is mine",
"updated": "2019-02-20T23:11:20.893755",
"eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
}
}

Set Channel Metadata

Description

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 Dart SDK:

pubnub.objects.setChannelMetadata(
String channelId,
ChannelMetadataInput channelMetadataInput,
{bool? includeCustomFields,
Keyset? keyset,
String? using}
)

class ChannelMetadataInput {
String? name;
String? description;
dynamic? custom;
}
ParameterTypeRequiredDefaultDescription
channelIdStringYesChannel name.
channelMetadataInputChannelMetadataInputYesChannel metadata details. Available options include name,description, and custom Objects filtering language doesn’t support filtering by custom properties.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

var channelMetadataInput = ChannelMetadataInput(
name: 'Channel name', description: 'A channel that is mine');

var result = await pubnub.objects
.setChannelMetadata('my_channel', channelMetadataInput);

Response

{
"status": 200,
"data": {
"id": "my-channel",
"name": "My channel",
"description": "A channel that is mine",
"updated": "2019-02-20T23:11:20.893755",
"eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
}
}

Remove Channel Metadata

Description

Removes the metadata from a specified channel.

Method(s)

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

pubnub.objects.removeChannelMetadata(
String channelId,
{Keyset? keyset,
String? using}
)
ParameterTypeRequiredDescription
channelIDStringYesChannel name.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

var result = await pubnub.objects.removeChannelMetadata('my_channel');

Response

The removeChannelMetadata() returns RemoveChannelMetadataResult which does not have actionable data. In case of an error, an exception with error details is thrown.

Channel Memberships

Get Channel Memberships

Description

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

Method(s)

To Get Channel Memberships you can use the following method(s) in the Dart SDK:

pubnub.objects.getMemberships(
{String? uuid,
int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeChannelFields,
bool? includeChannelCustomFields,
bool? includeCount = true,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
ParameterTypeRequiredDefaultDescription
uuidStringOptionaldefaultKeyset UUIDUnique UUID Metadata identifier.
If not supplied, then UUID from configuration will be used.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeChannelFieldsboolOptionalfalseInclude fields for channels metadata.
includeCustomChannelFieldsboolOptionalfalseInclude custom fields for channels metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var memberships = await pubnub.objects.getMemberships();

Response

{
"status": 200,
"data": [
{
"channel": {
"id": "my-channel",
"name": "My channel",
"description": "A channel that is mine",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
},
"custom": {
"starred": false
},
show all 38 lines

Set Channel Memberships

Description

Set channel memberships for a UUID.

Method(s)

To Set Channel Memberships you can use the following method(s) in the Dart SDK:

pubnub.objects.setMemberships(
List<MembershipMetadataInput> setMetadata,
{String? uuid,
int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeChannelFields,
bool? includeChannelCustomFields,
bool? includeCount = true,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
show all 20 lines
ParameterTypeRequiredDefaultDescription
setMetadataList<MembershipMetadataInput>YesThe memberships to be set.
uuidStringOptionalUnique UUID Metadata identifier.
If not supplied, then UUID from configuration will be used.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeChannelFieldsboolOptionalfalseInclude fields for channels metadata.
includeCustomChannelFieldsboolOptionalfalseInclude custom fields for channels metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var setMetadata = [
MembershipMetadataInput('my_channel', custom: {'starred': 'false'})
];

var result = await pubnub.objects
.setMemberships(setMetadata, includeChannelFields: true);

Response

{
"status": 200,
"data": [
{
"channel": {
"id": "my-channel",
"name": "My channel",
"description": "A channel that is mine",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
},
"custom": {
"starred": false
},
show all 38 lines

Remove Channel Memberships

Description

Remove channel memberships for a UUID.

Method(s)

To Remove Channel Memberships you can use the following method(s) in the Dart SDK:

pubnub.objects.removeMemberships(
Set<String> channelIds,
{String? uuid,
int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeChannelFields,
bool? includeChannelCustomFields,
bool? includeCount = true,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
ParameterTypeRequiredDefaultDescription
channelIdsSet<String>YesList of channels to remove from membership.
uuidStringOptionalUnique UUID Metadata identifier.
If not supplied, then UUID from configuration will be used.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeChannelFieldsboolOptionalfalseInclude fields for channels metadata.
includeCustomChannelFieldsboolOptionalfalseInclude custom fields for channels metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var result = await pubnub.objects.removeMemberships({'my_channel', 'main_channel'});

// for other uuid
var result = await pubnub.objects.removeMemberships({'my_channel'}, uuid: 'uuid1');

Response

{
"status": 200,
"data": [
{
"channel": {
"id": "my-channel",
"name": "My channel",
"description": "A channel that is mine",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
},
"custom": {
"starred": false
},
show all 38 lines

Manage Channel Memberships

Description

Manage a user's channel memberships.

Method(s)

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

pubnub.objects.manageMemberships(
List<MembershipMetadataInput> setMetadata,
Set<String> removeChannelIds,
{String? uuid,
int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeChannelFields,
bool? includeChannelCustomFields,
bool? includeCount,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
show all 21 lines
ParameterTypeRequiredDefaultDescription
setMetadataList<MembershipMetadataInput>YesThe memberships to be set.
channelIdsSet<String>YesList of channels to remove from membership.
uuidStringOptionalUnique UUID Metadata identifier.
If not supplied, then UUID from configuration will be used.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeChannelFieldsboolOptionalfalseInclude fields for channels metadata.
includeCustomChannelFieldsboolOptionalfalseInclude custom fields for channels metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var setMetadata = [
MembershipMetadataInput('my_channel', custom: {'starred': 'false'})
];
var result =
await pubnub.objects.manageMemberships(setMetadata, {'main_channel'});

Response

{
"status": 200,
"data": [
{
"channel": {
"id": "my-channel",
"name": "My channel",
"description": "A channel that is mine",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "RTc1NUQwNUItREMyNy00Q0YxLUJCNDItMEZDMTZDMzVCN0VGCg=="
},
"custom": {
"starred": false
},
show all 38 lines

Channel Members

Get Channel Members

Description

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.

Method(s)

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

pubnub.objects.getChannelMembers(
String channelId,
{int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeUUIDFields,
bool? includeUUIDCustomFields,
bool? includeCount = true,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
ParameterTypeRequiredDefaultDescription
channelIdStringyesChannel name.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeUUIDFieldsBooleanOptionalfalseInclude fields for UUIDs metadata.
includeUUIDCustomFieldsBooleanOptionalfalseInclude custom fields for UUIDs metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var channelMembers = await pubnub.objects.getChannelMembers('my_channel');

Response

{
"status": 200,
"data": [
{
"uuid": {
"id": "uuid-1",
"name": "John Doe",
"externalId": null,
"profileUrl": null,
"email": "someone@pubnub.com",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
},
"custom": {
show all 41 lines

Set Channel Members

Description

This method sets members in a channel.

Method(s)

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

pubnub.objects.setChannelMembers(
String channelId,
List<ChannelMemberMetadataInput> setMetadata,
{int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeUUIDFields,
bool? includeUUIDCustomFields,
bool? includeCount,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
show all 20 lines
ParameterTypeRequiredDefaultDescription
channelIdStringYesChannel name.
channelMetadataInputChannelMetadataInputYesThe metadata to be added.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeUUIDFieldsBooleanOptionalfalseInclude fields for UUIDs metadata.
includeUUIDCustomFieldsBooleanOptionalfalseInclude custom fields for UUIDs metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var setMetadata = [
ChannelMemberMetadataInput('myUUID', custom: {'role': 'admin'})
];
var result =
await pubnub.objects.setChannelMembers('my_channel', setMetadata);

Response

{
"status": 200,
"data": [
{
"uuid": {
"id": "uuid-1",
"name": "John Doe",
"externalId": null,
"profileUrl": null,
"email": "johndoe@pubnub.com",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
},
"custom": {
show all 41 lines

Remove Channel Members

Description

Remove members from a Channel.

Method(s)

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

pubnub.objects.removeChannelMembers(
String channelId,
Set<String> uuids,
{int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeUUIDFields,
bool? includeUUIDCustomFields,
bool? includeCount,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
)
ParameterTypeRequiredDefaultDescription
channelIdStringYesChannel name.
uuidsSet<String>YesUUIDs to remove from the channel.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeUUIDFieldsBooleanOptionalfalseInclude fields for UUIDs metadata.
includeUUIDCustomFieldsBooleanOptionalfalseInclude custom fields for UUIDs metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var result = await pubnub.objects
.removeChannelMembers('my_channel', {'uuid-1', 'uuid-2'});

Response

{
"status": 200,
"data": [
{
"uuid": {
"id": "uuid-1",
"name": "John Doe",
"externalId": null,
"profileUrl": null,
"email": "johndoe@pubnub.com",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
},
"custom": {
show all 41 lines

Manage Channel Members

Description

Set and Remove channel memberships for a user.

Method(s)

To Manage Channel Members you can use the following method(s) in the Dart SDK:

pubnub.objects.manageChannelMembers(
String channelId,
List<ChannelMemberMetadataInput> setMetadata,
Set<String> removeMemberUuids,
{int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeUUIDFields,
bool? includeUUIDCustomFields,
bool? includeCount = true,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}
show all 21 lines
ParameterTypeRequiredDefaultDescription
channelIdStringYesChannel name.
setMetadataList<ChannelMemberMetadataInput>YesThe metadata to set.
removeMemberUuidsSet<String>YesUUIDs to remove from the channel.
limitIntOptional100The number of objects to retrieve at a time.
startStringOptionalPreviously-returned cursor bookmark for fetching the next page.
endStringOptionalPreviously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter.
includeCustomFieldsboolOptionalfalseWhether to include the Custom field in the fetch response.
includeUUIDFieldsBooleanOptionalfalseInclude fields for UUIDs metadata.
includeUUIDCustomFieldsBooleanOptionalfalseInclude custom fields for UUIDs metadata.
includeCountboolOptionalfalseRequest IncludeCount to be included in paginated response. By default, includeCount is omitted.
filterStringOptionalnullExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sortSet<String>OptionalList of properties to sort by. Available options are id, name, and updated. Use asc or desc to specify sort direction.
keysetKeysetOptionalOverride for the PubNub default keyset configuration.
usingStringOptionalKeyset name from the keysetStore to be used for this method call.

Basic Usage

  var setMetadata = [
ChannelMemberMetadataInput('uuidToSet', custom: {'role': 'admin'})
];
var result = await pubnub.objects
.manageChannelMembers('my_channel', setMetadata, {'uuidToRemove'});

Response

{
"status": 200,
"data": [
{
"uuid": {
"id": "uuid-1",
"name": "John Doe",
"externalId": null,
"profileUrl": null,
"email": "johndoe@pubnub.com",
"custom": null,
"updated": "2019-02-20T23:11:20.893755",
"eTag": "MDcyQ0REOTUtNEVBOC00QkY2LTgwOUUtNDkwQzI4MjgzMTcwCg=="
},
"custom": {
show all 41 lines

Objects Filtering Language Definition

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.

  • 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.

Custom property filtering

You can't filter by custom properties.

<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>
show all 26 lines

Sample object filtering operations

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 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 '*\\**'