SelectUnity Channel Groups API Reference for Realtime Apps

These docs are for version 3.7.10 of the Unity SDK. To check out the docs for the latest version Click Here.
 

PubNub 4.x for Unity is our latest and greatest! Please click here for our PubNub 4.x for Unity docs and SDK.

PubNub 3.x for Unity will encounter End Of Life (EOL) Mar 12, 2019. All users currently on 3.x should begin migrating to 4.x. The 3.x SDK will continue to work. We will no longer support it and if you run into an issue, we will request that you upgrade to the latest version before solving the issue.

If you have questions about the PubNub for Unity SDK, please contact us at support@pubnub.com.

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


Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function adds a channel to a channel group.
Adding Channels is accomplished by using the following method(s) in the Unity SDK:
  1. ParameterTypeRequiredDescription
    channelsstring[]YesThe channel to add to the channel group.
    channelGroupstringYesThe channelGroup to add the channels to.
    userCallbackCallback Method of Type objectYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
  2. ParameterTypeRequiredDescription
    channelsstring[]YesSpecifies channelGroup to remove the channels from.
    channelGroupstringYesSpecifies channelGroup to fetch the channels for.
    userCallbackCallback Method of Type TYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
 string channelGroup = "family";
string[] channels = {
    "wife"
};

string channelGroup = "family";
pubnub.AddChannelsToChannelGroup<string> (
    channels,
    channelGroup,
    (string result)=>{
        UnityEngine.Debug.Log(string.Format ("Message: {0}", result));
    },
    (PubnubClientError pubnubError) =>{
        UnityEngine.Debug.Log(pubnubError.StatusCode);
    }
);
{
    "service" : "channel-registry",
    "status"  : 200,
    "error"   : false,
    "message" : "OK"
}

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function lists all the channels of the channel group.
Listing Channels is accomplished by using the following method(s) in the Unity SDK:
  1. ParameterTypeRequiredDescription
    channelGroupstringYesSpecifies channelGroup to fetch the channels for.
    userCallbackCallback Method of Type objectYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
  2. ParameterTypeRequiredDescription
    channelGroupstringYesSpecifies channelGroup to fetch the channels for.
    userCallbackCallback Method of Type TYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
 string channelGroup = "family";
string channelGroup = "family";
pubnub.GetChannelsForChannelGroup<string>(
	channelGroup,
	(string result) =>{
		UnityEngine.Debug.Log (result);
	}, 
	(PubnubClientError pubnubError) =>{
		UnityEngine.Debug.Log(pubnubError.StatusCode);
	}
);

{
	"status" : 200,
	"payload" : {
		"channels" : ["hi"], 
		"group" : "abcd"
	},
	"service" : "channel-registry",
	"error" : False
}

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channels from the channel group.
Removing Channels is accomplished by using the following method(s) in the Unity SDK:
  1. ParameterTypeRequiredDescription
    channelsstring[]YesSpecifies channelGroup to remove the channels from.
    channelGroupstringYesSpecifies channelGroup to remove the channels for.
    userCallbackCallback Method of Type TYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
  2. ParameterTypeRequiredDescription
    channelsstring[]YesSpecifies channelGroup to remove the channels from.
    channelGroupstringYesSpecifies channelGroup to fetch the channels for.
    userCallbackCallback Method of Type objectYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
Removing channels :
 string channelGroup = "family";
string[] channels = {
    "son"
};
string channelGroup = "family";
pubnub.RemoveChannelsFromChannelGroup<string> (
	channels,
	channelGroup,
	(string result)=>{
		UnityEngine.Debug.Log(string.Format ("Message: {0}", result));
	}, 
	(PubnubClientError pubnubError) =>{
		UnityEngine.Debug.Log(pubnubError.StatusCode);
	}
);

{
	"status" : 200,
	"message" : "OK",
	"service" : "channel-registry",
	"error" : False
}

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channel group.
Deleting Channel Group is accomplished by using the following method(s) in the Unity SDK:
  1. ParameterTypeRequiredDescription
    channelGroupstringYesSpecifies channelGroup to remove.
    userCallbackCallback Method of Type objectYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
  2. ParameterTypeRequiredDescription
    channelGroupstringYesSpecifies channelGroup to fetch the channels for.
    userCallbackCallback Method of Type TYesThis callback is called on success event.
    errorCallbackCallback Method of Type PubnubClientError YesThis callback is called on an error event.
Deleting Channel Group :
 string channelGroup = "family";
string channelGroup = "family";
pubnub.RemoveChannelGroup<string> (
	channelGroup,
	(string result) =>{
		UnityEngine.Debug.Log (result);
	},
	(PubnubClientError pubnubError) =>{
		UnityEngine.Debug.Log(pubnubError.StatusCode);
	}
);

{
	"status" : 200,
	"message" : "OK",
	"service" : "channel-registry",
	"error" : False
}