Channel Metadata

Manage channel data with BizOps Workspace

You can create, edit, or delete channels and their data using BizOps Workspace on Admin Portal that provides a preview of all channels available on your apps' keysets.

The App Context service allows you to persist metadata about channels, channel memberships, channel members, and users. The name and description are the predefined properties for channel metadata. Additionally, there is a custom property that you can use to store any custom attribute about a channel as per your business needs.

Illuminate & sensitive data

You can capture and track your App Context data in Illuminate for real-time decisioning and analytics. Illuminate captures all data you define with JSON paths and map when creating measures and dimensions for the Business Objects. For this reason, make sure you don’t include any PII data (e-mail address, profile URL, or IP address) in the custom fields of your App Context mappings.

Channel Metadata

The App Context service emits events when the metadata associated to a particular channel ID is set or deleted. Your application can receive these events in real time and dynamically react to data changes by updating the information visible on the front end of your app, for instance.

In the following sections, we're going to focus on what you can actually do with channels and their metadata.

Set Channel Metadata

You can set any of the predefined or custom channel metadata by providing the desired information as key/value pairs.

API limits

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

The code below adds the name, description, and custom owner information to the channel my_channel.

pubnub.objects.setChannelMetadata({
channel: "my_channel",
data: {
name: "main channel",
description: "This channel is for company wide chatter.",
custom: { "owner": "johndoe_1" }
}
});

On success, the PubNub SDK returns same metadata object along with status 200, it will also the fire objects -> channel -> set event so it can be consumed for other clients (users). Refer to Init & Add Listener section to learn more.

Get Channel Metadata

You can retrieve the metadata of a specific channel by simply providing the channel ID. You can optionally specify whether custom metadata should be included in the response. The code below returns all metadata of the channel with the ID my_channel.

pubnub.objects.getChannelMetadata({
channel: "my_channel"
});

On success, the PubNub SDK returns the metadata of the specified channel along with status 200.

Get Metadata for All Channels

You can also retrieve metadata for all the channels associated with the API key. You can optionally specify whether custom metadata should be included in the response. The code below returns all predefined and custom metadata of all channels:

pubnub.objects.getAllChannelMetadata();

On success, the PubNub SDK returns a paginated list of metadata for all channels.

Remove Channel Metadata

You can remove all metadata for a single channel. The code below removes all metadata of the channel with the ID my_channel.

Cascading deletes

Enabling referential integrity on your app’s keyset in the Admin Portal ensures that deleting a channel entity automatically deletes any memberships related to this channel. If it's not enabled, deleting a channel does not automatically delete any associated membership objects.

pubnub.objects.removeChannelMetadata({
channel: "my_channel"
});

On completion, the PubNub SDK will fire the objects -> channel -> delete event so it can be consumed for other clients (users). Refer to Receive Messages to learn more.

Last updated on