1 Initialize client

Publishing a JSON object to a channel is really easy. Here is an an example to get you started.

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 {
    self.client = [PubNub client];
    [self.client publish:@{@"announcement": @"Welcome to PubNub!"}
               toChannel:@"announcements" withCompletion:^(PNPublishStatus *status) {
        // Check whether request successfully completed or not.
        if (!status.isError) {
            // Message successfully published to specified channel.
        }
        // Request processing failed.
        else {
            // Handle message publish 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