Initialize the PubNub client and enable push notifications on channels to receive updates while the application is inactive.
Click to copy the blue snippets and then paste them into your code.#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 { self.client = [PubNub client]; UIUserNotificationType types = (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert); UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; [[UIApplication sharedApplication] registerForRemoteNotifications]; return YES; } - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [self.client addPushNotificationsOnChannels:@[@"announcements"] withDevicePushToken:deviceToken andCompletion:^(PNAcknowledgmentStatus *status) { // Check whether request successfully completed or not. if (!status.isError) { // Handle successful push notification enabling on passed channels. } // Request processing failed. else { // Handle modification error. Check 'category' property to find out possible issue because // of which request did fail. // // Request can be resent using: [status retry]; } }]; } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { } @end