Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Example/PubNub Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "PubNub Mac Example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 11.5;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.pubnub.PubNub-Mac-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -347,7 +347,7 @@
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "PubNub Mac Example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 11.5;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.pubnub.PubNub-Mac-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
47 changes: 15 additions & 32 deletions Example/PubNub Mac Example/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <PubNub/PubNub.h>
#import "AppDelegate.h"

@interface AppDelegate () <PNObjectEventListener>
@interface AppDelegate () <PNEventsListener>

#pragma mark - Properties

Expand Down Expand Up @@ -76,21 +76,14 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification {
- (void)pubNubInit {

// Initialize PubNub client.
self.myConfig = [PNConfiguration configurationWithPublishKey:_pubKey subscribeKey:_subKey];
self.myConfig = [PNConfiguration configurationWithPublishKey:_pubKey subscribeKey:_subKey userID:[self randomString]];

[self updateClientConfiguration];
[self printClientConfiguration];

// Bind config
self.client = [PubNub clientWithConfiguration:self.myConfig];

// Configure logger
self.client.logger.enabled = YES;
self.client.logger.writeToFile = YES;
self.client.logger.maximumLogFileSize = (10 * 1024 * 1024);
self.client.logger.maximumNumberOfLogFiles = 10;
[self.client.logger setLogLevel:PNVerboseLogLevel];

// Bind didReceiveMessage, didReceiveStatus, and didReceivePresenceEvent 'listeners' to this delegate
// just be sure the target has implemented the PNObjectEventListener extension
[self.client addListener:self];
Expand Down Expand Up @@ -157,19 +150,6 @@ - (void)tireKicker {
[self pubNubAESDecrypt];
[self pubNubAESEncrypt];

#pragma mark - Message Size Check Methods

[self pubNubSizeOfMessage];

}

- (void)pubNubSizeOfMessage{

[self.client sizeOfMessage:@"Connected! I'm here!" toChannel:_channel1
withCompletion:^(NSInteger size) {

NSLog(@"^^^^ Message size: %@", @(size));
}];
}

- (void)pubNubAESDecrypt{
Expand Down Expand Up @@ -213,7 +193,10 @@ - (void)pubNubGetAllPushNotifications {
- (void)pubNubSetState {

__weak __typeof(self) weakSelf = self;
[self.client setState:@{[self randomString] : @{[self randomString] : [self randomString]}} forUUID:_myConfig.uuid onChannel:_channel1 withCompletion:^(PNClientStateUpdateStatus *status) {
[self.client setState:@{[self randomString] : @{[self randomString] : [self randomString]}}
forUUID:_myConfig.userID
onChannel:_channel1
withCompletion:^(PNClientStateUpdateStatus *status) {

__strong __typeof(self) strongSelf = weakSelf;
[strongSelf handleStatus:status];
Expand All @@ -222,7 +205,8 @@ - (void)pubNubSetState {

- (void)pubNubGetState{

[self.client stateForUUID:_myConfig.uuid onChannel:_channel1
[self.client stateForUUID:_myConfig.userID
onChannel:_channel1
withCompletion:^(PNChannelClientStateResult *result, PNErrorStatus *status) {

if (status) {
Expand Down Expand Up @@ -585,7 +569,7 @@ - (void)handleErrorStatus:(PNErrorStatus *)status {

if (status.category == PNAccessDeniedCategory) {

NSLog(@"^^^^ handleErrorStatus: PAM Error: for resource Will Auto Retry?: %@", status.willAutomaticallyRetry ? @"YES" : @"NO");
NSLog(@"^^^^ handleErrorStatus: PAM Error");

[self handlePAMError:status];
}
Expand All @@ -594,9 +578,8 @@ - (void)handleErrorStatus:(PNErrorStatus *)status {
NSLog(@"Decryption error. Be sure the data is encrypted and/or encrypted with the correct cipher key.");
NSLog(@"You can find the raw data returned from the server in the status.data attribute: %@", status.associatedObject);
if (status.operation == PNSubscribeOperation) {

NSLog(@"Decryption failed for message from channel: %@",
((PNMessageData *)status.associatedObject).channel);
PNSubscribeMessageEventData *data = status.associatedObject;
NSLog(@"Decryption failed for message from channel: %@\nmessage: %@", data.channel, data.message);
}
}
else if (status.category == PNMalformedFilterExpressionCategory) {
Expand Down Expand Up @@ -775,13 +758,13 @@ Looks like client received a lot of messages at once (larget than specified
#pragma mark - Configuration

- (void)updateClientConfiguration {

// Set PubNub Configuration
self.myConfig.TLSEnabled = NO;
self.myConfig.uuid = [self randomString];
self.myConfig.origin = @"pubsub.pubnub.com";
self.myConfig.authKey = _authKey;

// Configure logger
self.myConfig.logLevel = PNDebugLogLevel;

// Presence Settings
self.myConfig.presenceHeartbeatValue = 120;
self.myConfig.presenceHeartbeatInterval = 5;
Expand All @@ -807,7 +790,7 @@ - (void)printClientConfiguration {
NSLog(@"TLSEnabled: %@", (self.myConfig.isTLSEnabled ? @"YES" : @"NO"));
NSLog(@"Origin: %@", self.myConfig.origin);
NSLog(@"authKey: %@", self.myConfig.authKey);
NSLog(@"UUID: %@", self.myConfig.uuid);
NSLog(@"UUID: %@", self.myConfig.userID);

// Time Token Handling Settings
NSLog(@"keepTimeTokenOnChannelChange: %@",
Expand Down
7 changes: 7 additions & 0 deletions Example/PubNub Mac Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>ps.pndsn.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>pubsub.pubnub.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
Expand Down
41 changes: 11 additions & 30 deletions Example/PubNub/PNAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
- (void)pubNubInit {

// Initialize PubNub client.
self.myConfig = [PNConfiguration configurationWithPublishKey:_pubKey subscribeKey:_subKey userID:@"pubnub"];
self.myConfig = [PNConfiguration configurationWithPublishKey:_pubKey subscribeKey:_subKey userID:[self randomString]];

[self updateClientConfiguration];
[self printClientConfiguration];

// Bind config
self.client = [PubNub clientWithConfiguration:self.myConfig];

// Configure logger
self.client.logger.enabled = YES;
self.client.logger.writeToFile = YES;
self.client.logger.maximumLogFileSize = (10 * 1024 * 1024);
self.client.logger.maximumNumberOfLogFiles = 10;
[self.client.logger setLogLevel:PNVerboseLogLevel];


// Bind didReceiveMessage, didReceiveStatus, and didReceivePresenceEvent 'listeners' to this delegate
// just be sure the target has implemented the PNObjectEventListener extension
Expand Down Expand Up @@ -159,19 +151,6 @@ - (void)tireKicker {
[self pubNubAESDecrypt];
[self pubNubAESEncrypt];

#pragma mark - Message Size Check Methods

[self pubNubSizeOfMessage];

}

- (void)pubNubSizeOfMessage{

[self.client sizeOfMessage:@"Connected! I'm here!" toChannel:_channel1
withCompletion:^(NSInteger size) {

NSLog(@"^^^^ Message size: %@", @(size));
}];
}

- (void)pubNubAESDecrypt{
Expand Down Expand Up @@ -215,7 +194,9 @@ - (void)pubNubGetAllPushNotifications {
- (void)pubNubSetState {

__weak __typeof(self) weakSelf = self;
[self.client setState:@{[self randomString] : @{[self randomString] : [self randomString]}} forUUID:_myConfig.uuid onChannel:_channel1 withCompletion:^(PNClientStateUpdateStatus *status) {
[self.client setState:@{[self randomString] : @{[self randomString] : [self randomString]}}
forUUID:_myConfig.userID
onChannel:_channel1 withCompletion:^(PNClientStateUpdateStatus *status) {

__strong __typeof(self) strongSelf = weakSelf;
[strongSelf handleStatus:status];
Expand All @@ -224,7 +205,7 @@ - (void)pubNubSetState {

- (void)pubNubGetState{

[self.client stateForUUID:_myConfig.uuid onChannel:_channel1
[self.client stateForUUID:_myConfig.userID onChannel:_channel1
withCompletion:^(PNChannelClientStateResult *result, PNErrorStatus *status) {

if (status) {
Expand Down Expand Up @@ -586,7 +567,7 @@ - (void)handleErrorStatus:(PNErrorStatus *)status {

if (status.category == PNAccessDeniedCategory) {

NSLog(@"^^^^ handleErrorStatus: PAM Error: for resource Will Auto Retry?: %@", status.willAutomaticallyRetry ? @"YES" : @"NO");
NSLog(@"^^^^ handleErrorStatus: PAM Error");

[self handlePAMError:status];
}
Expand Down Expand Up @@ -778,13 +759,13 @@ Looks like client received a lot of messages at once (larget than specified
#pragma mark - Configuration

- (void)updateClientConfiguration {

// Set PubNub Configuration
self.myConfig.TLSEnabled = NO;
self.myConfig.uuid = [self randomString];
self.myConfig.origin = @"pubsub.pubnub.com";
self.myConfig.authKey = _authKey;


// Configure logger
self.myConfig.logLevel = PNDebugLogLevel;

// Presence Settings
self.myConfig.presenceHeartbeatValue = 120;
self.myConfig.presenceHeartbeatInterval = 5;
Expand All @@ -810,7 +791,7 @@ - (void)printClientConfiguration {
NSLog(@"TLSEnabled: %@", (self.myConfig.isTLSEnabled ? @"YES" : @"NO"));
NSLog(@"Origin: %@", self.myConfig.origin);
NSLog(@"authKey: %@", self.myConfig.authKey);
NSLog(@"UUID: %@", self.myConfig.uuid);
NSLog(@"UUID: %@", self.myConfig.userID);

// Time Token Handling Settings
NSLog(@"keepTimeTokenOnChannelChange: %@",
Expand Down
Loading