---
source_url: https://www.pubnub.com/docs/sdks/objective-c/api-reference/channel-groups
title: Channel Groups API for Objective-C SDK
updated_at: 2026-05-25T11:28:24.986Z
sdk_name: PubNub Objective-C SDK
sdk_version: 7.0.2
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Channel Groups API for Objective-C SDK

PubNub Objective-C SDK, use the latest version: 7.0.2

Install:

```bash
pod install PubNub@7.0.2
```

[Channel groups](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) allow PubNub developers to bundle thousands of [channels](https://www.pubnub.com/docs/general/channels/overview) into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.

:::note Channel group operations
You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.
:::

## Add channels to a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the PubNub [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function adds channels to a channel group.

### Method(s)

`Adding Channels` is accomplished by using the following method(s) in the Objective-C SDK:

```objectivec
- (void)addChannels:(NSArray<NSString *> *)channels 
            toGroup:(NSString *)group 
     withCompletion:(nullable PNChannelGroupChangeCompletionBlock)block;
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channels | NSArray | Yes |  | List of channel names which should be added to the group. |
| group | NSString | Yes |  | Name of the group into which channels should be added. |
| block | PNChannelGroupChangeCompletionBlock | Optional |  | `Channels` addition process completion block which pass only one argument - request processing status to report about how data pushing was successful or not. |

### Sample code

#### Add channels

```objectivec
// Initialize PubNub client with your keys
PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo" 
                                                                 subscribeKey:@"demo"
                                                                       userID:@"testUser"];
PubNub *client = [PubNub clientWithConfiguration:configuration];

// Define channel group and channels to add
NSString *channelGroup = @"family";
NSArray *channels = @[@"wife", @"husband", @"children"];

NSLog(@"Adding channels %@ to channel group: %@", channels, channelGroup);

// Add channels to the channel group
PNChannelGroupManageRequest *request = [PNChannelGroupManageRequest requestToAddChannels:channels 
                                                                          toChannelGroup:channelGroup];

[client manageChannelGroupWithRequest:request completion:^(PNAcknowledgmentStatus *status) {
    if (!status.isError) {
        NSLog(@"Channels successfully added to channel group!");
        
        // Verify by listing channels in the group
        PNChannelGroupFetchRequest *request = [PNChannelGroupFetchRequest requestWithChannelGroup:channelGroup];
        [client fetchChannelsForChannelGroupWithRequest:request
            completion:^(PNChannelGroupChannelsResult *result, PNErrorStatus *status) {
            if (!status.isError) {
                NSLog(@"Channels in group '%@': %@", channelGroup, result.data.channels);
            } else {
                NSLog(@"Error listing channels in group: %@", status.errorData.information);
            }
        }];
    } else {
        NSLog(@"Error adding channels to group: %@", status.errorData.information);
        NSLog(@"Error category: %@", @(status.category));
    }
}];
```

### Response

Response objects which is returned by client when Add Channels to Group API is used:

```objectivec
@interface PNAcknowledgmentStatus : PNErrorStatus

@end
```

## List channels in a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function lists all channels in a channel group.

### Method(s)

`Listing Channels` is accomplished by using the following method(s) in the Objective-C SDK:

```objectivec
- (void)channelsForGroup:(NSString *)group 
          withCompletion:(PNGroupChannelsAuditCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `group` *Type: NSString | Name of the group from which `channels` should be fetched. |
| `block` *Type: PNClientChannelsForGroupRequestHandlingBlock | `Channels` audition process completion `block` which pass two arguments: result - in case of successful request processing data field will contain results of channel groups `channels` audition operation; status - in case if error occurred during request processing. |

### Sample code

#### List channels

```objectivec
NSString *channelGroup = @"family";
```

```objectivec
[self.client channelsForGroup:channelGroup withCompletion:^(PNChannelGroupChannelsResult *result,
                                                            PNErrorStatus *status) {

    if (!status) {

        // Handle downloaded list of chanels using: result.data.channels
    }
    else {

        /**
         Handle channels for group audition error. Check 'category' property
         to find out possible reason because of which request did fail.
         Review 'errorData' property (which has PNErrorData data type) of status
         object to get additional information about issue.

         Request can be resent using: [status retry];
         */
    }
}];
```

### Response

Response objects which is returned by client when Add Channels to Group API is used:

```objectivec
@interface PNChannelGroupChannelsData : PNServiceData

// Registered channels within channel group.
@property (nonatomic, readonly, strong) NSArray<NSString *> *channels;

@end

@interface PNChannelGroupChannelsResult : PNResult

// Stores reference on channel group's channels list audit request processing information.
@property (nonatomic, nonnull, readonly, strong) PNChannelGroupChannelsData *data;

@end
```

## Remove channels from a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function removes channels from a channel group.

### Method(s)

`Removing Channels` is accomplished by using the following method(s) in the Objective-C SDK:

```objectivec
- (void)removeChannels:(NSArray<NSString *> *)channels 
             fromGroup:(NSString *)group 
        withCompletion:(nullable PNChannelGroupChangeCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray | List of channel names which should be removed from group. `If empty list passed whole channel group will be removed.` |
| `group` *Type: NSString | Channel group from which channels should be removed. |
| `block`Type: PNChannelGroupChangeCompletionBlock | Channels removal process completion block which pass only one argument - request processing status to report about how data pushing was successful or not. |

### Sample code

#### Remove channels

```objectivec
NSString *channelGroup = @"family";
```

```objectivec
[self.client removeChannels:@[@"son"] fromGroup:channelGroup
             withCompletion:^(PNAcknowledgmentStatus *status) {

    if (!status.isError) {

        // Handle successful channels list modification for group.
    }
    else {

        /**
         Handle channels list modification for group error. Check 'category' property
         to find out possible reason because of which request did fail.
         Review 'errorData' property (which has PNErrorData data type) of status
         object to get additional information about issue.

         Request can be resent using: [status retry];
         */
    }
}];
```

### Response

Response objects which is returned by client when Remove Channels to Group API is used:

```objectivec
@interface PNAcknowledgmentStatus : PNErrorStatus

@end
```

## Delete a channel group

:::note Requires Stream Controller add-on
This method requires that the *Stream Controller* add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

This function deletes a channel group.

### Method(s)

`Deleting Channel Group` is accomplished by using the following method(s) in the Objective-C SDK:

```objectivec
- (void)removeChannelsFromGroup:(NSString *)group 
                 withCompletion:(nullable PNChannelGroupChangeCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `group` *Type: NSString | Name of the `group` from which all `channels` should be removed. |
| `block`Type: PNChannelGroupChangeCompletionBlock | Channel group removal process completion `block` which pass only one argument - request processing status to report about how data pushing was successful or not. |

### Sample code

Deleting Channel Group :

```objectivec
NSString *channelGroup = @"family";
```

```objectivec
[self.client removeChannelsFromGroup:channelGroup withCompletion:^(PNAcknowledgmentStatus *status) {

    if (!status.isError) {

        // Handle successful channel group removal.
    }
    else {

        /**
         Handle channel group removal error. Check 'category' property
         to find out possible reason because of which request did fail.
         Review 'errorData' property (which has PNErrorData data type) of status
         object to get additional information about issue.

         Request can be resent using: [status retry];
         */
    }
}];
```

### Response

Response objects which is returned by client when Remove Channel Group API is used:

```objectivec
@interface PNAcknowledgmentStatus : PNErrorStatus

@end
```

## Terms in this document

* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
* **PubNub** - PubNub is a real-time messaging platform that provides APIs and SDKs for building scalable applications. It handles the complex infrastructure of real-time communication, including: Message delivery and persistence, Presence detection, Access control, Push notifications, File sharing, Serverless processing with Functions and Events & Actions, Analytics and monitoring with BizOps Workspace, AI-powered insights with Illuminate.