PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›API Reference

unity

  • Getting Started
  • API Reference

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

Channel Groups API for PubNub Unity 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 Unity V4 SDK:

Note

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

  1. pubnub.AddChannelsToChannelGroup().Channels(List<string>).ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
    
    ParameterTypeRequiredDescription
    ChannelsListYesThe Channels to add to the channel group.
    ChannelGroupstringYesThe ChannelGroup to add the channels to.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackYesPNCallback of type PNChannelGroupsAddChannelResult.

Basic Usage

Adding Channels :

pubnub.AddChannelsToChannelGroup()
    .Channels(new List<string> (){"my_channel"})
    .ChannelGroup("channelGroup")
    .Async((result, status) => {
        if(status.Error){
            Debug.Log (string.Format("In Example, AddChannelsToChannelGroup Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
        } else {
            Debug.Log (string.Format("DateTime {0}, In Example AddChannelsToChannelGroup, result: {1}", DateTime.UtcNow, result.Message));
        }
    });

Returns

The AddChannelsToChannelGroup() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError().

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 Unity V4 SDK:

  1. pubnub.ListChannelsForChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
    
    ParameterTypeRequiredDescription
    ChannelGroupstringYesChannel group to fetch the channels.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackYesPNCallback of type PNChannelGroupsAllChannelsResult.

Basic Usage

Listing Channels:

pubnub.ListChannelsForChannelGroup()
    .ChannelGroup("cg")
    .Async((result, status) => {
        if(status.Error){
            Debug.Log (string.Format("In Example, ListAllChannelsOfGroup Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
        } else {
            Debug.Log (string.Format("In Example ListAllChannelsOfGroup, result: {0}", (result.Channels!=null)?string.Join(",", result.Channels.ToArray()):""));
        }
    });

Returns

The ListChannelsForChannelGroup() operation returns a PNChannelGroupsAllChannelsResult which contains the following operations:

MethodTypeDescription
ChannelsListList of channels of a channel group.

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 Unity V4 SDK:

  1. pubnub.RemoveChannelsFromChannelGroup().Channels(new List<string>).ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
    
    ParameterTypeRequiredDescription
    ChannelsListYesThe Channels to remove from the channel group.
    ChannelGroupstringYesSpecifies ChannelGroup to remove the channels from.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackOptionalPNCallback of type PNChannelGroupsRemoveChannelResult.

Basic Usage

Removing channels:

pubnub.RemoveChannelsFromChannelGroup()
    .Channels(new List<string> (){"son"})
    .ChannelGroup("family")
    .Async((result, status) => {
        Debug.Log ("in RemoveChannelsFromCG");
        if(status.Error){
            Debug.Log (string.Format("In Example, RemoveChannelsFromCG Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
        } else {
            Debug.Log (string.Format("DateTime {0}, In RemoveChannelsFromCG, result: {1}", DateTime.UtcNow, result.Message));
        }
    });

Returns

The RemoveChannelsFromChannelGroup() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.IsError().

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 Unity V4 SDK:

  1. pubnub.DeleteChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
    
    ParameterTypeRequiredDescription
    ChannelGroupstringYesSpecifies ChannelGroup to remove.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackOptionalPNCallback of type PNChannelGroupsDeleteGroupResult.

Basic Usage

Deleting Channel Group:

pubnub.DeleteChannelGroup()
    .ChannelGroup("family")
    .Async((result1, status1) => {
        if(status1.Error){
            Debug.Log (string.Format("In Example, DeleteChannelsFromChannelGroup Error: {0} {1} {2}", status1.StatusCode, status1.ErrorData, status1.Category));
        } else {
            Debug.Log (string.Format("DateTime {0}, In Example DeleteChannelsFromChannelGroup, result: {1}", DateTime.UtcNow, result1.Message));
        }
    });

Response

The DeleteChannelGroup() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.IsError().

← Access ManagerMessage Persistence →
  • Adding Channels
    • Description
    • Method(s)
    • Basic Usage
    • Returns
  • Listing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Returns
  • Removing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Returns
  • Deleting Channel Group
    • Description
    • Method(s)
    • Basic Usage
    • Response
© PubNub Inc. - Privacy Policy