App Context API for PubNub Dart 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 you need to build innovative, reliable, scalable applications. Use App Context 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
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}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
limit | int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCount | bool | Optional | true | Request IncludeCount to be included in paginated response. By default, IncludeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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 linesGet 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 Dart SDK:
pubnub.objects.getUUIDMetadata(
{String? uuid,
Keyset? keyset,
String? using,
bool? includeCustomFields}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid | String | Optional | defaultKeyset UUID | The UUID to get the metadata for. |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. | |
includeCustomFields | bool | Optional | false | Whether 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
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;
}
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuidMetadataInput | UuidMetadataInput | Yes | UUID metadata details. Available options include name ,email ,custom ,externalId , and profileUrl . App Context filtering language doesn’t support filtering by custom properties. | |
uuid | String | Optional | defaultKeyset UUID | UUID to set the metadata to. |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. |
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
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
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}
)
Parameter | Type | Required | Description |
---|---|---|---|
uuid | String | Optional | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. |
using | String | Optional | Keyset 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
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}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
limit | int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeCount | bool | Optional | true | Request IncludeCount to be included in paginated response. By default, IncludeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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 linesGet 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 Dart SDK:
pubnub.objects.getChannelMetadata(
String channelId,
{Keyset? keyset,
String? using,
bool? includeCustomFields}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | String | Yes | Channel name. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. | |
includeCustomFields | bool | Optional | false | Whether 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
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;
}
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | String | Yes | Channel name. | |
channelMetadataInput | ChannelMetadataInput | Yes | Channel metadata details. Available options include name ,description , and custom App Context filtering language doesn’t support filtering by custom properties. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. |
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
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
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}
)
Parameter | Type | Required | Description |
---|---|---|---|
channelID | String | Yes | Channel name. |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. |
using | String | Optional | Keyset 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
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}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid | String | Optional | defaultKeyset UUID | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeChannelFields | bool | Optional | false | Include fields for channels metadata. |
includeCustomChannelFields | bool | Optional | false | Include custom fields for channels metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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 linesSet Channel Memberships
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 linesParameter | Type | Required | Default | Description |
---|---|---|---|---|
setMetadata | List<MembershipMetadataInput> | Yes | The memberships to be set. | |
uuid | String | Optional | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. | |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeChannelFields | bool | Optional | false | Include fields for channels metadata. |
includeCustomChannelFields | bool | Optional | false | Include custom fields for channels metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. |
API limits
To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.
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 linesRemove Channel Memberships
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}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channelIds | Set<String> | Yes | List of channels to remove from membership. | |
uuid | String | Optional | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. | |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeChannelFields | bool | Optional | false | Include fields for channels metadata. |
includeCustomChannelFields | bool | Optional | false | Include custom fields for channels metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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 linesManage Channel Memberships
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 linesParameter | Type | Required | Default | Description |
---|---|---|---|---|
setMetadata | List<MembershipMetadataInput> | Yes | The memberships to be set. | |
channelIds | Set<String> | Yes | List of channels to remove from membership. | |
uuid | String | Optional | Unique UUID Metadata identifier. If not supplied, then UUID from configuration will be used. | |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeChannelFields | bool | Optional | false | Include fields for channels metadata. |
includeCustomChannelFields | bool | Optional | false | Include custom fields for channels metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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 linesChannel Members
Get Channel Members
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}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | String | yes | Channel name. | |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeUUIDFields | Boolean | Optional | false | Include fields for UUIDs metadata. |
includeUUIDCustomFields | Boolean | Optional | false | Include custom fields for UUIDs metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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 linesSet Channel Members
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 linesParameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | String | Yes | Channel name. | |
channelMetadataInput | ChannelMetadataInput | Yes | The metadata to be added. | |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeUUIDFields | Boolean | Optional | false | Include fields for UUIDs metadata. |
includeUUIDCustomFields | Boolean | Optional | false | Include custom fields for UUIDs metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset name from the keysetStore to be used for this method call. |
API limits
To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.
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 linesRemove Channel Members
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}
)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | String | Yes | Channel name. | |
uuids | Set<String> | Yes | UUIDs to remove from the channel. | |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeUUIDFields | Boolean | Optional | false | Include fields for UUIDs metadata. |
includeUUIDCustomFields | Boolean | Optional | false | Include custom fields for UUIDs metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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 linesManage Channel Members
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 linesParameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | String | Yes | Channel name. | |
setMetadata | List<ChannelMemberMetadataInput> | Yes | The metadata to set. | |
removeMemberUuids | Set<String> | Yes | UUIDs to remove from the channel. | |
limit | Int | Optional | 100 | The number of objects to retrieve at a time. |
start | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. | |
end | String | Optional | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. | |
includeCustomFields | bool | Optional | false | Whether to include the Custom field in the fetch response. |
includeUUIDFields | Boolean | Optional | false | Include fields for UUIDs metadata. |
includeUUIDCustomFields | Boolean | Optional | false | Include custom fields for UUIDs metadata. |
includeCount | bool | Optional | false | Request IncludeCount to be included in paginated response. By default, includeCount is omitted. |
filter | String | Optional | null | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. |
sort | Set<String> | Optional | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. | |
keyset | Keyset | Optional | Override for the PubNub default keyset configuration. | |
using | String | Optional | Keyset 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