2 Subscribe to channel group(s)

To receive messages from the channel group, subscribe to the channel group created in the previous step.

Click to copy the blue snippets and then paste them into your code.

AppDelegate.m

#import "AppDelegate.h"
#import <PubNub/PubNub.h>
#import <PubNubBridge/PubNub+FAB.h>


@interface AppDelegate ()

@property (nonatomic, strong) PubNub *client;

@end


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    __weak __typeof(self) weakSelf = self;
    self.client = [PubNub client];
    [self.client addChannels:@[@"announcements", @"lobby"] toGroup:@"tradeshow"
              withCompletion:^(PNAcknowledgmentStatus *status) {
        __strong __typeof(self) strongSelf = weakSelf;
        // Check whether request successfully completed or not.
        if (!status.isError) {
            [strongSelf.client addListener:strongSelf];
            [strongSelf.client subscribeToChannelGroups:@[@"tradeshow"] withPresence:NO];
        }
        // Request processing failed.
        else {
            // Handle channels list modification for group error. Check 'category' property to find out
            // possible issue because of which request did fail.
            //
            // Request can be resent using: [status retry];
        }
    }];
    return YES;
}

@end