PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›API Reference

objective-C

  • 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 Objective-C 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-onRequires 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 Objective-C SDK:

- (void)addChannels:(NSArray<NSString *> *)channels toGroup:(NSString *)group withCompletion:(nullable PNChannelGroupChangeCompletionBlock)block;
ParameterTypeRequiredDescription
channelsNSArrayYesList of channel names which should be added to the group.
groupNSStringYesName of the group into which channels should be added.
blockPNChannelGroupChangeCompletionBlockNoChannels addition process completion block which pass only one argument - request processing status to report about how data pushing was successful or not.

Basic Usage

Adding Channels :

NSString *channelGroup = @"family";
[self.client addChannels: @[@"wife"] toGroup: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 Add Channels to Group API is used:

@interface PNAcknowledgmentStatus : PNErrorStatus

@end

Listing Channels

Requires Stream Controller add-onRequires 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 Objective-C SDK:

- (void)channelsForGroup:(NSString *)group withCompletion:(PNGroupChannelsAuditCompletionBlock)block;
ParameterTypeRequiredDescription
groupNSStringYesName of the group from which channels should be fetched.
blockPNClientChannelsForGroupRequestHandlingBlockYesChannels 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.

Basic Usage

Listing Channels :

NSString *channelGroup = @"family";
[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:

@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

Removing Channels

Requires Stream Controller add-onRequires 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 Objective-C SDK:

- (void)removeChannels:(NSArray<NSString *> *)channels fromGroup:(NSString *)group withCompletion:(nullable PNChannelGroupChangeCompletionBlock)block;
ParameterTypeRequiredDescription
channelsNSArrayYesList of channel names which should be removed from group. If empty list passed whole channel group will be removed.
groupNSStringYesChannel group from which channels should be removed.
blockPNChannelGroupChangeCompletionBlockNoChannels removal process completion block which pass only one argument - request processing status to report about how data pushing was successful or not.

Basic Usage

Removing channels :

NSString *channelGroup = @"family";
[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:

@interface PNAcknowledgmentStatus : PNErrorStatus

@end

Deleting Channel Group

Requires Stream Controller add-onRequires 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 Objective-C SDK:

- (void)removeChannelsFromGroup:(NSString *)group withCompletion:(nullable PNChannelGroupChangeCompletionBlock)block;
ParameterTypeRequiredDescription
groupNSStringYesName of the group from which all channels should be removed.
blockPNChannelGroupChangeCompletionBlockNoChannel group removal process completion block which pass only one argument - request processing status to report about how data pushing was successful or not.

Basic Usage

Deleting Channel Group :

NSString *channelGroup = @"family";
[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:

@interface PNAcknowledgmentStatus : PNErrorStatus

@end
← 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