PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›API Reference

vue

  • Getting Started
  • API Reference

    • Configuration
    • Publish & Subscribe
    • Presence
    • Access Manager
    • Channel Groups
    • Message Persistence
    • Mobile Push
    • Miscellaneous
  • Status Events
  • Troubleshooting
  • Change Log
  • Platform Support

Channel Groups API for PubNub Vue SDK

Channel Groups allows PubNub developers to bundle thousands of channels into a group that can be identified by name. These Channel Groups can then be subscribed to, receiving data from the many backend-channels the channel group contains.

Learn more about our Channel Groups here.

Adding Channels

Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-

Description

This function adds a channel to a channel group.

Method(s)

Adding Channels is accomplished by using the following method(s) in the Vue V4 SDK:

Note

200 channels can be added to the channel group per API call.

  1. pubnub.channelGroups.addChannels({Array channels, String channelGroup},Function callback)
    
    ParameterTypeRequiredDescription
    Operation ArgumentsHashYesA hash of arguments.
    channelsArrayYesThe channel to add to the channel group.
    channelGroupStringYesThe channelGroup to add the channels to.
    callbackFunctionOptionalExecutes on a successful/unsuccessful addChannels.

Basic Usage

Adding Channels :

import PubNubVue from 'pubnub-vue';

const pubnub = PubNubVue.getInstance();

pubnub.channelGroups.addChannels(
    {
        channels: ['ch1', 'ch2'],
        channelGroup: "myChannelGroup"
    },
    function(status) {
        if (status.error) {
            console.log("operation failed w/ status: ", status);
        } else {
            console.log("operation done!");
        }
    }
);

Response

{
    error: false,
    operation: "PNAddChannelsToGroupOperation",
    statusCode: 200
}

Listing Channels

Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-

Description

This function lists all the channels of the channel group.

Method(s)

Listing Channels is accomplished by using the following method(s) in the Vue V4 SDK:

  1. pubnub.channelGroups.listChannels({String channelGroup},Function callback)
    
    ParameterTypeRequiredDescription
    Operation ArgumentsHashYesA hash of arguments.
    channelGroupStringYesChannel Group to list the channel(s) of.
    callbackFunctionOptionalExecutes on a successful/unsuccessful listChannels.

Basic Usage

Listing Channels:

import PubNubVue from 'pubnub-vue';

const pubnub = PubNubVue.getInstance();

// assuming an intialized PubNub instance already exists
pubnub.channelGroups.listChannels(
    {
        channelGroup: "myChannelGroup"
    },
    function(status, response) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
            return;
        }

        console.log("listing push channel for device");
        response.channels.forEach( function(channel) {
            console.log(channel);
        });
    }
);

Response

// Example of Status
{
    error: false,
    operation: "PNChannelsForGroupOperation",
    statusCode: 200
}

// Example of Response
{
    channels: ["ch1", "ch2"]
}

Removing Channels

Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-

Description

This function removes the channels from the channel group.

Method(s)

Removing Channels is accomplished by using the following method(s) in the Vue V4 SDK:

  1. pubnub.channelGroups.removeChannels({Array channels, String channelGroup},Function callback)
    
    ParameterTypeRequiredDescription
    Operation ArgumentsHashYesA hash of arguments.
    channelsArrayYesThe channel to remove from the channel group.
    channelGroupStringYesThe channelGroup to remove the channels from.
    callbackFunctionOptionalExecutes on a successful/unsuccessful removeChannels.

Basic Usage

Removing channels:

import PubNubVue from 'pubnub-vue';

const pubnub = PubNubVue.getInstance();

// assuming an initialized PubNub instance already exists
pubnub.channelGroups.removeChannels(
    {
        channels: ['son'],
        channelGroup: "family"
    },
    function(status) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
        } else {
            console.log("operation done!");
        }
    }
);

Response

{
    error: false,
    operation: "PNRemoveChannelsFromGroupOperation",
    statusCode: 200
}

Deleting Channel Group

Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-

Description

This function removes the channel group.

Method(s)

Deleting Channel Group is accomplished by using the following method(s) in the Vue V4 SDK:

  1. pubnub.channelGroups.deleteGroup({String channelGroup},Function callback)
    
    ParameterTypeRequiredDescription
    Operation ArgumentsHashYesA hash of arguments.
    channelGroupStringYesThe channelGroup to remove.
    callbackFunctionOptionalExecutes on a successful/unsuccessful deleteGroup.

Basic Usage

Deleting Channel Group:

import PubNubVue from 'pubnub-vue';

const pubnub = PubNubVue.getInstance();

pubnub.channelGroups.deleteGroup(
    {
        channelGroup: "family"
    },
    function(status) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
        } else {
            console.log("operation done!");
        }
    }
);

Response

{
    error: false,
    operation: "PNRemoveGroupOperation",
    statusCode: 200
}
← Access ManagerMessage Persistence →
  • Adding Channels
    • Description
    • Method(s)
    • Basic Usage
    • Response
  • Listing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Response
  • Removing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Response
  • Deleting Channel Group
    • Description
    • Method(s)
    • Basic Usage
    • Response
© PubNub Inc. - Privacy Policy