Giter Site home page Giter Site logo

objective-c's Introduction

PubNub 5.4.1 for iOS 9+

Twitter Twitter Releases CocoaPods Compatible Carthage compatible Platform Docs Coverage Build Status

This is the official PubNub Objective-C SDK repository.

PubNub takes care of the infrastructure and APIs needed for the realtime communication layer of your application. Work on your app's logic and let PubNub handle sending and receiving data across the world in less than 100ms.

Get keys

You will need the publish and subscribe keys to authenticate your app. Get your keys from the Admin Portal.

Configure PubNub

  1. Install the latest cocoapods gem by running the gem install cocoapods command. If you already have this gem, make sure to update to the latest version by running the gem update cocoapods command.

  2. Create a new Xcode project and create a Podfile in the root folder of the project:

    pod init
    
    platform :ios, '9.0'
    
    target 'application-target-name' do
        use_frameworks!
    
        pod "PubNub", "~> 4"
    end

    If you want to include additional pods or add other targets, add their entries to this Podfile as well. Refer to the CocoaPods documentation for more information on Podfile configuration.

  3. Install your pods by running the pod install command from the directory which contains your Podfile. After installing your Pods, you should work with the CocoaPods-generated workspace and not the original project file.

  4. Import the PubNub headers in the classes where you want to use PubNub:

    #import <PubNub/PubNub.h>
  5. Configure your keys:

    // Initialize and configure PubNub client instance
    PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey: @"myPublishKey" subscribeKey:@"mySubscribeKey"];
    configuration.uuid = @"myUniqueUUID";
    
    self.client = [PubNub clientWithConfiguration:configuration];

Add event listeners

// Listener's class should conform to `PNEventsListener` protocol
// in order to have access to available callbacks.

// Adding listener.
[pubnub addListener:self];

// Callbacks listed below.

- (void)client:(PubNub *)pubnub didReceiveMessage:(PNMessageResult *)message {
    NSString *channel = message.data.channel; // Channel on which the message has been published
    NSString *subscription = message.data.subscription; // Wild-card channel or channel on which PubNub client actually subscribed
    NSNumber *timetoken = message.data.timetoken; // Publish timetoken
    id msg = message.data.message; // Message payload
    NSString *publisher = message.data.publisher; // Message publisher
}

- (void)client:(PubNub *)pubnub didReceiveSignal:(PNSignalResult *)signal {
    NSString *channel = message.data.channel; // Channel on which the signal has been published
    NSString *subscription = message.data.subscription; // Wild-card channel or channel on which PubNub client actually subscribed
    NSNumber *timetoken = message.data.timetoken; // Signal timetoken
    id msg = message.data.message; // Signal payload
    NSString *publisher = message.data.publisher; // Signal publisher
}

- (void)client:(PubNub *)pubnub didReceiveMessageAction:(PNMessageActionResult *)action {
    NSString *channel = action.data.channel; // Channel on which the message has been published
    NSString *subscription = action.data.subscription; // Wild-card channel or channel on which PubNub client actually subscribed
    NSString *event = action.data.event; // Can be: added or removed
    NSString *type = action.data.action.type; // Message action type
    NSString *value = action.data.action.value; // Message action value
    NSNumber *messageTimetoken = action.data.action.messageTimetoken; // Timetoken of the original message
    NSNumber *actionTimetoken = action.data.action.actionTimetoken; // Timetoken of the message action
    NSString *uuid = action.data.action.uuid; // UUID of user which added / removed message action
}

- (void)client:(PubNub *)pubnub didReceivePresenceEvent:(PNPresenceEventResult *)event {
    NSString *channel = message.data.channel; // Channel on which presence changes
    NSString *subscription = message.data.subscription; // Wild-card channel or channel on which PubNub client actually subscribed
    NSString *presenceEvent = event.data.presenceEvent; // Can be: join, leave, state-change, timeout or interval
    NSNumber *occupancy = event.data.presence.occupancy; // Number of users subscribed to the channel (not available for state-change event)
    NSNumber *timetoken = event.data.presence.timetoken; // Presence change timetoken
    NSString *uuid = event.data.presence.uuid; // UUID of user for which presence change happened

    // Only for 'state-change' event
    NSDictionary *state = event.data.presence.state; // User state (only for state-change event)

    // Only for 'interval' event
    NSArray<NSString *> *join = event.data.presence.join; // UUID of users which recently joined channel
    NSArray<NSString *> *leave = event.data.presence.leave; // UUID of users which recently leaved channel
    NSArray<NSString *> *timeout = event.data.presence.timeout; // UUID of users which recently timed out on channel
}

- (void)client:(PubNub *)pubnub didReceiveObjectEvent:(PNObjectEventResult *)event {
    NSString *channel = event.data.channel; // Channel to which the event belongs
    NSString *subscription = event.data.subscription; // Wild-card channel or channel on which PubNub client actually subscribed
    NSString *event = event.data.event; // Can be: set or delete
    NSString *type = event.data.type; // Entity type: channel, uuid or membership
    NSNumber *timestamp = event.data.timestamp; // Event timestamp

    PNChannelMetadata *channelMetadata = event.data.channelMetadata; // Updated channel metadata (only for channel entity type)
    PNUUIDMetadata *uuidMetadata = event.data.uuidMetadata; // Updated channel metadata (only for uuid entity type)
    PNMembership *membership = event.data.membership; // Updated channel metadata (only for membership entity type)
}

- (void)client:(PubNub *)pubnub didReceiveFileEvent:(PNFileEventResult *)event {
    NSString *channel = event.data.channel; // Channel to which file has been uploaded
    NSString *subscription = event.data.subscription; // Wild-card channel or channel on which PubNub client actually subscribed
    id message = event.data.message; // Message added for uploaded file
    NSString *publisher = event.data.publisher; // UUID of file uploader
    NSURL *fileDownloadURL = event.data.file.downloadURL; // URL which can be used to download file
    NSString *fileIdentifier = event.data.file.identifier; // Unique file identifier
    NSString *fileName = event.data.file.name; // Name with which file has been stored remotely
}

- (void)client:(PubNub *)pubnub didReceiveStatus:(PNStatus *)status {
    PNStatusCategory category = status.category; // One of PNStatusCategory fields to identify status of operation processing
    PNOperationType operation = status.operation; // One of PNOperationType fields to identify for which operation status received
    BOOL isError = status.isError; // Whether any kind of error happened.
    NSInteger statusCode = status.statusCode; // Related request processing status code
    BOOL isTLSEnabled = status.isTLSEnabled; // Whether secured connection enabled
    NSString *uuid = status.uuid; // UUID which configured for passed client
    NSString *authKey = status.authKey; // Auth key configured for passed client
    NSString *origin = status.origin; // Origin against which request has been sent
    NSURLRequest *clientRequest = status.clientRequest; // Request which has been used to send last request (may be nil)
    BOOL willAutomaticallyRetry = status.willAutomaticallyRetry; // Whether client will try to perform automatic retry

    // Following is available when operation == PNSubscribeOperation,
    // because status is PNSubscribeStatus instance in this case
    PNSubscribeStatus *subscribeStatus = (PNSubscribeStatus *)status;
    NSNumber *currentTimetoken = subscribeStatus.currentTimetoken; // Timetoken which has been used for current subscribe request
    NSNumber *lastTimeToken = subscribeStatus.lastTimeToken; // Timetoken which has been used for previous subscribe request
    NSArray<NSString *> *subscribedChannels = subscribeStatus.subscribedChannels; // List of channels on which client currently subscribed
    NSArray<NSString *> *subscribedChannelGroups = subscribeStatus.subscribedChannelGroups; // List of channel groups on which client currently subscribed
    NSString *channel = subscribeStatus.data.channel; // Name of channel to which status has been received
    NSString *subscription = subscribeStatus.data.subscription; // Wild-card channel or channel on which PubNub client actually subscribed
    NSNumber *timetoken = subscribeStatus.data.timetoken; // Timetoken at which event arrived
    NSDictionary *userMetadata = subscribeStatus.data.userMetadata; // Metadata / envelope which has been passed along with event

    // Following is available when isError == YES,
    // because status is PNErrorStatus instance in this case
    PNErrorStatus *errorStatus = (PNErrorStatus *)status;
    id associatedObject = errorStatus.associatedObject; // Data which may contain related information (not decrypted message for example)
    NSArray<NSString *> *erroredChannels = errorStatus.errorData.channels; // List of channels for which error reported (mostly because of PAM)
    NSArray<NSString *> *erroredChannelGroups = errorStatus.errorData.channelGroups; // List of channel groups for which error reported (mostly because of PAM)
    NSString *errorInformation = errorStatus.errorData.information; // Stringified information about error
    id errorData = errorStatus.errorData.data; // Additional error information from PubNub service
}

Publish/subscribe

[self.client publish:@{ @ "msg": @"hello" } toChannel:targetChannel 
      withCompletion:^(PNPublishStatus *publishStatus) {
          if (!publishStatus.isError) {
              // Message successfully published to specified channel.
          } else {
              /**
               * Handle message publish 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: [publishStatus retry];
               */
          }
}];

[self.client subscribeToChannels: @[@"hello-world-channel"] withPresence:YES];

Documentation

Support

If you need help or have a general question, contact [email protected].

License

The PubNub Swift SDK is released under the PubNub Software Development Kit License.

See LICENSE for details.

objective-c's People

Contributors

aaronlevy avatar client-engineering-bot avatar crimsonred avatar jcavar avatar jeffgreen7 avatar jguz-pubnub avatar jon513 avatar jtmilne avatar jzucker2 avatar maxpresman avatar michaljolender avatar mouhcine-elamine avatar musashiwasajedi avatar parfeon avatar pubnubcraig avatar samiahmedsiddiqui avatar seba-aln avatar speedeverjiang avatar stephenlb avatar techwritermat avatar tullerval avatar vosovets avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

objective-c's Issues

Submodule error in repository

When cloning this repository as a submodule the following error occurs:

No submodule mapping found in .gitmodules for path 'iOS/HOWTO/pncl'

PubNub sends push notifications to those already subscribed and present in the chat room?

Each of my PNMessages have the following dictionary (this is an example):

{
@"aps": {@"alert": "HELLO!"},
@"HELLO!"
}

However, this message is being both delivered via push notification and via PubNub's websocket. Am I constructing my PNMessage incorrectly? Ideally, I want push to deliver only to those not present in the chat room (as in, the phone is locked).

A work-around I've found is to call [PubNub removeAllPushNotificationsForDevicePushToken: withCompletionHandlingBlock:] every single time the application becomes active, and call [PubNub enablePushNotificationsForChannels: withDevicePushToken:] whenever the application becomes inactive. But this is very unideal, since you can imagine a variety of scenarios where this would fail.

Intermittent exception - class not key value coding-compliant

I am getting an exception sometimes on startup. On startup, I established a connection, wait 1 sec before subscribing and registering for presence and another 5sec before retrieving the participant list.

Sometimes it works other times it crashes. I am running on the simulator.

๏ฟฝ[;2013-07-23 21:16:23.765 App[89668:18e03] PNMessagingChannel (0x9d72070) {INFO} Reconnecting by request
2013-07-23 21:16:23.765 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" closed read stream
2013-07-23 21:16:23.766 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" closed write stream
2013-07-23 21:16:23.766 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" closed all streams
2013-07-23 21:16:23.767 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" should reconnect
2013-07-23 21:16:23.767 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" not configured yet
2013-07-23 21:16:23.767 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" configuration
2013-07-23 21:16:23.767 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" configured
2013-07-23 21:16:23.768 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" connecting
2013-07-23 21:16:23.768 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" opened read stream
2013-07-23 21:16:23.768 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} "PNMessagingConnectionIdentifier" opened write stream
2013-07-23 21:16:23.768 App[89668:18e03] PNConnection (0x9d73ce0) {INFO} Reconnecting "PNMessagingConnectionIdentifier" channel
2013-07-23 21:16:23.838 App[89668:18e03] PNConnection (0x9d73ce0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] STREAM OPENED (STREAM IS OPENED)
2013-07-23 21:16:23.838 App[89668:18e03] PNConnection (0x9d73ce0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] STREAM OPENED (STREAM IS OPENED)
2013-07-23 21:16:24.088 App[89668:18e03] PNConnection (0x9d73ce0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-07-23 21:16:24.088 App[89668:18e03] PNMessagingChannel (0x9d72070) {INFO} WILL START REQUEST PROCESSING: <PNSubscribeRequest: 0x99760c0> [BODY: /subscribe/MY-SUB-KEY/ABCChannel,DEFChannel,LMChannel-pnpres,ABCChannel-pnpres,PMChannel-pnpres,MLChannel-pnpres/s_0f0d1/13746285834923304?uuid=1127a2b0-3851-4106-91b8-cdac36b8da42]
2013-07-23 21:16:24.089 App[89668:18e03] PNMessagingChannel (0x9d72070) {INFO} DID SEND REQUEST: <PNSubscribeRequest: 0x99760c0> [BODY: /subscribe/MY-SUB-KEY/ABCChannel,DEFChannel,LMChannel-pnpres,ABCChannel-pnpres,PMChannel-pnpres,MLChannel-pnpres/s_0f0d1/13746285834923304?uuid=1127a2b0-3851-4106-91b8-cdac36b8da42]
2013-07-23 21:16:24.089 App[89668:18e03] PNConnection (0x9d73ce0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-07-23 21:16:34.089 App[89668:18e03] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<PNChannel 0xb14ad40> valueForUndefinedKey:]: this class is not key value coding-compliant for the key observedChannel.'
*** First throw call stack:
(0x3473012 0x2d24e7e 0x34fbfb1 0x1229d1d 0x119600b 0x1195fbd 0x1195dc4 0x2ebc00 0x2ec2f7 0x11c62c0 0x3432376 0x3431e06 0x3419a82 0x3418f44 0x3418e1b 0x378a7e3 0x378a668 0x1db9ffc 0x246d 0x2395)
libc++abi.dylib: terminate called throwing an exception
(

History timestamp accuracy error

Conversion between PubNub's timestamp token and NSDate loses accuracy.
Example log:

2013-03-29 19:54:53.519 MyApp[5959:907] PNResponseDeserialize: RAW DATA: h_1299a([[<App message content>],13645645353437104,13645645389661303])
2013-03-29 19:54:53.551 MyApp[5959:907] DEBUG: Received history from 13645645350000000 to 13645645380000000

Here is how i converted the date to string:

NSLog(@"DEBUG: Received history from %@ to %@", PNStringFromUnsignedLongLongNumber(PNTimeTokenFromDate(startDate)), PNStringFromUnsignedLongLongNumber(PNTimeTokenFromDate(endDate)));

Crash on subscribe to channel with wrong subscribe key

Hi guys.
I found the problem with SDK. When i try to subscribe to channel, having wrong subscribe key in configuration, the app crashes with message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean rangeOfString:]: unrecognized selector sent to instance 0x2bc1350

The problem is in [PNError errorWithResponseErrorMessage:] method.
You are expecting to get NSString as param:

error = [PNError errorWithResponseErrorMessage:[responseData valueForKey:kPNResponseErrorMessageKey]];

But response json holds integer value for kPNResponseErrorMessageKey (@"error").
here is JSON:

{
error = 1;
message = "Invalid Subscribe Key";
payload = {
channels = (
a
);
};
service = "Access Manager";
status = 400;
}

It's seems like API changes related issue. Just letting you know.
Thanks and good luck.
(Sorry for poor english)

Occasional crash soon after connecting

Sometimes soon after connecting to PubNub and subscribing to a channel, a crash occurs on the following line:

PNResponseDeserialize.m

            cursor = [chunkedData rangeOfData:self.endLineCharactersData
                                      options:(NSDataSearchOptions)0
                                        range:nextSearchRange];

Exception:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSConcreteMutableData rangeOfData:options:range:]: range {359, 4294967284} causes integer overflow'

Sample apps don't make clear how to add your own subscribe and publish keys

I had to search through all the files to see that buried in PNDefaultConfiguration.h the keys are set to @"demo" and @"demo". Even now I'm not sure if I'm supposed to edit that file to override or if there is some other mechanism to specifying the keys.
The PDF's don't mention anything regarding the keys either.

Please add support for forced reconnection.

Hello,

Would like to ask for method which could be used to forced PubNub reconnect.
Method for disconnect could look [PubNub disconnectWithDoneBlock: ] where inside done block calling [PubNub connect] would be guaranteed to work.

Krzysztof

Confusion regarding IOS implementation

Hi,
In IOS 3.4 SDK, if I use

  • (void)subscribeOnChannels:(NSArray *)channels;

and subscribe to multiple channels, will this connect to each channel indvidually or through multiplexing ???

More importantly , will this count as single connection to my count in the Pricing Package or will this count as multiple connections

Subscription failed by timeout

Hello,

We are writing iOS chat application. All was working great before we add APN support.
Here is my workflow:

  1. App opened
  2. Update channels ids from server
  3. Subscribe on channels if I have device token I also enabled APN for channels

Also I send request for enabling APN right after I got device token if I've already got channels id from server. So I can got token before or after I got channels ids.

I always receive subscription by timeout. I've tried to removed code for push notification but problem is still here. Here is my log:

2013-08-23 06:53:50.956 ProfileCode[5085:907] My token is: <30ac2427 f57f53ee 5a79c4d1 505cca7b b708ae18 a9f48bd2 ca58b189 e8968f41>
2013-08-23 06:53:50:985 ProfileCode[5085:2311] call enablePushNotificationsOnChannels: at ChatEngine
2013-08-23 06:53:55.889 ProfileCode[5085:907] PNConfiguration (0x1c58aa70)
{WARN} Before running in production, please contact [email protected] for your custom origin.
Please set the origin from ios.pubnub.com to IUNDERSTAND.pubnub.com to remove this warning.
2013-08-23 06:53:55.891 ProfileCode[5085:907] PNReachability (0x1c577aa0) STOP REACHABILITY OBSERVATION
2013-08-23 06:53:55.899 ProfileCode[5085:907] PNReachability (0x1c577aa0) START REACHABILITY OBSERVATION
2013-08-23 06:53:56.151 ProfileCode[5085:907] PNReachability (0x1c577aa0) PubNub services reachability changed [CONNECTED? YES]
2013-08-23 06:53:56.153 ProfileCode[5085:907] PubNub (0x1d05b720) IS CONNECTED? YES (STATE: 1)
2013-08-23 06:53:56.156 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO} "<PNConnection: 0x1c59e070>" configuration
2013-08-23 06:53:56.159 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO} "PNMessagingConnectionIdentifier" connecting
2013-08-23 06:53:56.161 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO} "PNMessagingConnectionIdentifier" opened read stream
2013-08-23 06:53:56.162 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO} "PNMessagingConnectionIdentifier" opened write stream
2013-08-23 06:53:56.164 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO} "<PNConnection: 0x1c58fc90>" configuration
2013-08-23 06:53:56.166 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO} "PNServiceConnectionIdentifier" connecting
2013-08-23 06:53:56.168 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO} "PNServiceConnectionIdentifier" opened read stream
2013-08-23 06:53:56.169 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO} "PNServiceConnectionIdentifier" opened write stream
2013-08-23 06:53:56.279 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] STREAM OPENED (STREAM IS OPENED)
2013-08-23 06:53:56.281 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] STREAM OPENED (STREAM IS OPENED)
2013-08-23 06:53:56.289 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] STREAM OPENED (STREAM IS OPENED)
2013-08-23 06:53:56.290 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] STREAM OPENED (STREAM IS OPENED)
2013-08-23 06:53:56:297 ProfileCode[5085:2311] PubNub Connection Success: ios.pubnub.com
2013-08-23 06:53:56:304 ProfileCode[5085:2311] call attachChannels: at ChatEngine
2013-08-23 06:53:56:308 ProfileCode[5085:2311] starting attachChannels: (
yYd010XTJk,
phFZ8cGuoe
)
2013-08-23 06:53:56.910 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-23 06:53:56.912 ProfileCode[5085:907] PNMessagingChannel (0x1c5731b0) {INFO} WILL START REQUEST PROCESSING: <PNTimeTokenRequest: 0x1c59cbe0> [BODY: /time/t_40d05]
2013-08-23 06:53:56.914 ProfileCode[5085:907] PNMessagingChannel (0x1c5731b0) {INFO} DID SEND REQUEST: <PNTimeTokenRequest: 0x1c59cbe0> [BODY: /time/t_40d05][WAITING FOR COMPLETION? NO]
2013-08-23 06:53:56.917 ProfileCode[5085:907] PNMessagingChannel (0x1c5731b0) {INFO} WILL START REQUEST PROCESSING: <PNSubscribeRequest: 0x1c595250> [BODY: /subscribe/sub-c-bbe1d18a-80ab-11e2-b64e-12313f022c90/phFZ8cGuoe,yYd010XTJk/s_29e12/0?uuid=1cf38361-88c7-4b1e-b3cf-0169a98e6b56]
2013-08-23 06:53:56.919 ProfileCode[5085:907] PNMessagingChannel (0x1c5731b0) {INFO} DID SEND REQUEST: <PNSubscribeRequest: 0x1c595250> [BODY: /subscribe/sub-c-bbe1d18a-80ab-11e2-b64e-12313f022c90/phFZ8cGuoe,yYd010XTJk/s_29e12/0?uuid=1cf38361-88c7-4b1e-b3cf-0169a98e6b56][WAITING FOR COMPLETION? YES]
2013-08-23 06:53:56.922 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-23 06:53:56.976 ProfileCode[5085:907] Warning: A long-running Parse operation is being executed on the main thread.
Break on warnParseOperationOnMainThread() to debug.
2013-08-23 06:53:57.333 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] HAS DATA FOR READ OUT (STREAM IS OPENED)
2013-08-23 06:53:57.335 ProfileCode[5085:907] PNResponseDeserialize (0x1c55eb70) {INFO} RAW DATA: t_40d05([13772372383118602])
2013-08-23 06:53:57.339 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-23 06:53:57.340 ProfileCode[5085:907] PNServiceChannel (0x1c5ab9c0) {INFO} WILL START REQUEST PROCESSING: <PNTimeTokenRequest: 0x1c5b1250> [BODY: /time/t_164f2]
2013-08-23 06:53:57.343 ProfileCode[5085:907] PNServiceChannel (0x1c5ab9c0) {INFO} DID SEND REQUEST: <PNTimeTokenRequest: 0x1c5b1250> [BODY: /time/t_164f2]
2013-08-23 06:53:57.344 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-23 06:53:57.401 ProfileCode[5085:907] Warning: A long-running Parse operation is being executed on the main thread.
Break on warnParseOperationOnMainThread() to debug.
2013-08-23 06:53:57.837 ProfileCode[5085:907] PNConnection (0x1c58fc90) {INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] HAS DATA FOR READ OUT (STREAM IS OPENED)
2013-08-23 06:53:57.839 ProfileCode[5085:907] PNResponseDeserialize (0x1c556d80) {INFO} RAW DATA: t_164f2([13772372387419212])
2013-08-23 06:53:57.841 ProfileCode[5085:907] PNServiceChannel (0x1c5ab9c0) {INFO} RECIEVED RESPONSE:
HTTP STATUS CODE: 200
RESPONSE SIZE: 28
RESPONSE CONTENT SIZE: 268
IS JSONP: YES
CALLBACK METHOD: t
REQUEST IDENTIFIER: 164f2
RESPONSE: (
13772372387419212
)
2013-08-23 06:53:57.844 ProfileCode[5085:907] PNServiceChannel (0x1c5ab9c0) {INFO} PARSED DATA: PNTimeTokenResponseParser (0x1c540e20): <time token: 13772372387419212>
2013-08-23 06:53:57.845 ProfileCode[5085:907] PNServiceChannel (0x1c5ab9c0) {INFO} OBSERVED REQUEST COMPLETED: (null)
2013-08-23 06:54:06.921 ProfileCode[5085:907] error.associatedObject: (
phFZ8cGuoe,
yYd010XTJk
)
2013-08-23 06:54:06.923 ProfileCode[5085:907] we can't subscribe on channel error: Domain=com.pubnub.pubnub; Code=106; Description="Subscription failed by timeout"; Reason="Looks like there is some packets lost because of which request failed by timeout"; Fix suggestion="Try send request again later."; Associated object=(
"PNChannel(0x1c5b3530) phFZ8cGuoe",
"PNChannel(0x1c5b2160) yYd010XTJk"
)
2013-08-23 06:54:06:928 ProfileCode[5085:2311] performSelector:@selector(attachChannels:) after delay at message center
2013-08-23 06:54:06.930 ProfileCode[5085:907] subscribeOnChannels : Domain=com.pubnub.pubnub; Code=106; Description="Subscription failed by timeout"; Reason="Looks like there is some packets lost because of which request failed by timeout"; Fix suggestion="Try send request again later."; Associated object=(
"PNChannel(0x1c5b3530) phFZ8cGuoe",
"PNChannel(0x1c5b2160) yYd010XTJk"
)
2013-08-23 06:54:06:936 ProfileCode[5085:2311] performSelector:@selector(attachChannels:) after delay recursivly
2013-08-23 06:54:09:935 ProfileCode[5085:2311] starting attachChannels: (
phFZ8cGuoe,
yYd010XTJk
)
2013-08-23 06:54:09.938 ProfileCode[5085:907] PNMessagingChannel (0x1c5731b0) {INFO} WILL START REQUEST PROCESSING: <PNSubscribeRequest: 0x1d070fd0> [BODY: /subscribe/sub-c-bbe1d18a-80ab-11e2-b64e-12313f022c90/phFZ8cGuoe,yYd010XTJk/s_b41a9/0?uuid=1cf38361-88c7-4b1e-b3cf-0169a98e6b56]
2013-08-23 06:54:09.941 ProfileCode[5085:907] PNMessagingChannel (0x1c5731b0) {INFO} DID SEND REQUEST: <PNSubscribeRequest: 0x1d070fd0> [BODY: /subscribe/sub-c-bbe1d18a-80ab-11e2-b64e-12313f022c90/phFZ8cGuoe,yYd010XTJk/s_b41a9/0?uuid=1cf38361-88c7-4b1e-b3cf-0169a98e6b56][WAITING FOR COMPLETION? YES]
2013-08-23 06:54:09.943 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-23 06:54:09:947 ProfileCode[5085:2311] starting attachChannels: (
"PNChannel(0x1c5b3530) phFZ8cGuoe",
"PNChannel(0x1c5b2160) yYd010XTJk"
)
2013-08-23 06:54:10.073 ProfileCode[5085:907] PNConnection (0x1c59e070) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] HAS DATA FOR READ OUT (STREAM IS OPENED)
2013-08-23 06:54:10.076 ProfileCode[5085:907] PNResponseDeserialize (0x1c55eb70) {INFO} RAW DATA: t_40d05([13772372383118602])
2013-08-23 06:54:19.942 ProfileCode[5085:907] error.associatedObject: (
phFZ8cGuoe,
yYd010XTJk
)
2013-08-23 06:54:19.944 ProfileCode[5085:907] we can't subscribe on channel error: Domain=com.pubnub.pubnub; Code=106; Description="Subscription failed by timeout"; Reason="Looks like there is some packets lost because of which request failed by timeout"; Fix suggestion="Try send request again later."; Associated object=(
"PNChannel(0x1c5b3530) phFZ8cGuoe",
"PNChannel(0x1c5b2160) yYd010XTJk"
)

Unsubscribe request doesn't get executed

I've been playing around with the presence monitoring with our iOS application and I've noticed a weird behaviour that I'll describe below.

First off, what we're doing is automatically unsubscribing from a channel when the application is suspended. We introduce a 30 second delay in this suspension though (so as to handle quick suspend/resumes gracefully) and execute the unsubscribe in the background.

So the sequence of events is as follows:

  1. User suspends the application.
  2. In response, we call [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^() { ... }]; so that we can keep executing while in the background.
  3. We call dispatch_after() with a 30 second delay and a block that will perform our unsubscribe.
  4. In order to have PubNub execute in the background, we also override -(BOOL)shouldRunClientInBackground; and return YES if we have any outstanding background tasks (which means we have a delayed unsubscribe).

If everything goes normally, we unsubscribe after 30 seconds and in the unsubscribe success/failure delegate calls, we clean up our background task so that the app can fully suspend.

However, if during the 30 second window, I perform the following steps:

  1. Go to the settings screen and enable Airplane Mode --> wait for PubNub to disconnect (the disconnect delegate functions are called)
  2. Disable Airplane Mode and wait for PubNub to reconnect.

When the unsubscribe method is called, neither the success nor the failure handler is called. In addition to this, the presence isn't updated on the PubNub website's Dev Console. I believe this means the notification isn't actually sent or is malformed in some way. The result of this is that our application keeps running in the background when it shouldn't. We have to wait for the success/fail delegate call as PubNub executes the unsubscribe asynchronously and if we cleaned up the background task immediately after we call unsubscribe, the network call isn't sent.

Here's a snippet from my log when the unsubscribe method is called:

[2013-10-16 08:42:25:184] I [PNMacro.m:251] PNLog
PubNub (0x1f51a630) TRYING TO UNSUBSCRIBE FROM CHANNELS: (
    "PNChannel(0x2016ca30) v-6151"
) (STATE: 'connected')
[2013-10-16 08:42:25:184] I [PNMacro.m:251] PNLog
PubNub (0x4da31c) >>>>>> {LOCK}{#7} TURN ON (+[PubNub performAsyncLockingBlock:postponedExecutionBlock:])
[2013-10-16 08:42:25:184] I [PNMacro.m:251] PNLog
PubNub (0x4da31c) >>>>>> {LOCK}{#35} TURN ON (__79+[PubNub unsubscribeFromChannels:withPresenceEvent:andCompletionHandlingBlock:]_block_invoke)
[2013-10-16 08:42:26:884] I [PNMacro.m:251] PNLog
PubNub (0x1f51a630) UNSUBSCRIBE FROM CHANNELS: (
    "PNChannel(0x2016ca30) v-6151"
) (STATE: 'connected')
[2013-10-16 08:42:26:923] I [PNMacro.m:251] PNLog
PNMessagingChannel (0x1f5e1960) {INFO}[CHANNEL::<PNMessagingChannel: 0x1f5e1960>] LEAVING SPECIFIC SET OF CHANNELS... (STATE: 8)
[2013-10-16 08:42:26:960] I [PNMacro.m:251] PNLog
PubNub (0x1f51a630) WILL UNSUBSCRIBE FROM: (
    "PNChannel(0x2016ca30) v-6151"
)
[2013-10-16 08:42:26:960] I [PNMacro.m:251] PNLog
PubNub (0x1f51a630) >>>>>> {LOCK}{#17} TURN ON (-[PubNub messagingChannel:willUnsubscribeFromChannels:])
[2013-10-16 08:42:26:962] I [PNMacro.m:251] PNLog
PNConnection (0x1f5e18c0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] WRITE BUFFER CONTENT (STATE: 33658880)
[2013-10-16 08:42:26:970] I [PNMacro.m:251] PNLog
PNMessagingChannel (0x1f5e1960) {INFO}[CHANNEL::<PNMessagingChannel: 0x1f5e1960>] WILL START REQUEST PROCESSING: <PNTimeTokenRequest: 0x22d5f930> [BODY: /time/t_a5565?auth=sec-c-SECRET_CODE_HERE](STATE: 8)
[2013-10-16 08:42:26:971] I [PNMacro.m:251] PNLog
PNConnection (0x1f5e18c0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] WRITTEN WHOLE REQUEST BODY (191/191 BYTES)(STATE: 100767744)
[2013-10-16 08:42:26:983] I [PNMacro.m:251] PNLog
PNMessagingChannel (0x1f5e1960) {INFO}[CHANNEL::<PNMessagingChannel: 0x1f5e1960>] DID SEND REQUEST: <PNTimeTokenRequest: 0x22d5f930> [BODY: /time/t_a5565?auth=sec-c-SECRET_CODE_HERE][WAITING FOR COMPLETION? NO](STATE: 8)
[2013-10-16 08:42:26:993] I [PNMacro.m:251] PNLog
PNConnection (0x1f5e18c0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)(STATE: 33658880)
[2013-10-16 08:42:26:993] I [PNMacro.m:251] PNLog
PNConnection (0x1f5e18c0) {INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] NOTHING TO WRITE (STATE: 33658880)

3.6.2 Released!

Some small bug fixes, new Presence state-change handling, and new iPad demo app.

DECRYPTION_ERROR when it's not

Hey guys,

We're getting a decryption error on iOS whenever we send a message with a length of a multiple of 16 characters. This is kinda a huge deal.

Affects:
Version 3.4 (looks like it isn't fixed in 3.5 unless there's a fix higher up in the call stack).

Repro steps:

  1. Open the dev console and subscribe to a channel with a cipher.
  2. Launch the iOS application with the same subscription settings.
  3. Sent one of the following messages:
    {"wifiStatus":0}
    {"wifiStat":"1"}
    {"wifiStat":"1","xwifiStat":"1"}
    Note that they are 16 and 32 bits long.
  4. The iOS client subscribed to the same channel will report a DECRYPTION_ERROR.

Fix:

Here's the lines to remove to correct the issue. Not sure what this check is supposed to do (we have room remaining in our buffer but no more data? what about when we have room in our buffer and date remaining?) In any case, I think this is a poor check as the key on iOS is for AES128 and according to the dev console it uses AES256. I'm not too keen on the different, but I'd expect up to 16 bits to be hanging over on decrypted message perhaps?

+++ Data/Crypto/PNCryptoHelper.m        (working copy)
@@ -397,11 +397,6 @@
                 size_t remainingUnprocessedDataLength;
                 processingStatus = CCCryptorFinal(cryptor, processedDataEndPointer, unfilledSize, &remainingUnprocessedDataLength);
                 [processedData setLength:(updatedProcessedDataLength+remainingUnprocessedDataLength)];
-                
-                if (unfilledSize > 0 && remainingUnprocessedDataLength == 0) {
-                    
-                    processingStatus = kCCDecodeError;
-                }
             }

requestHistoryForChannel: callback never called

Hi. I use that call to get the channel history:

[PubNub requestHistoryForChannel: from: to: withCompletionBlock:^(...) {
       //stuff
    }];

But it seems if there's no Internet connection (airplane mode) the completion block is never called.
Can you check that?
Thanks a lot.

JSONKit and iOS 7

Can I get some clarification on what it means to "remove" JSONKit on iOS 7? What if you have an app the is being developed to support both iOS 7 and iOS 6?

Scalability

Have you done any performance testing on client devices related to the number of messages that can be processed per second, etc?

We are looking at vastly increasing our volume of messages. Wondering if you have any info on this.

PubNub Crashes upon subscription

Hello everyone,

I am working on a messaging app using PubNub. So far I have had no issues connecting to the PubNub network. I have been following this tutorial to help get started: http://www.pubnub.com/docs/objective-c/iOS/tutorial/data-push.html

However, for some reason my application crashes upon execution of this code:
[PubNub subscribeOnChannel:my_channel];

When the above line is commented out, my program works fine. When it is implemented, it crashes. The rest of my code is just as it is in the tutorial, except for my publish key and subscription key.

The error output I am receiving is the following:

2014-06-13 20:11:08.324 BoltBeta[12131:60b] -[**NSCFString percentEscapedString]: unrecognized selector sent to instance 0x9cb5c70
2014-06-13 20:11:08.327 BoltBeta[12131:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString percentEscapedString]: unrecognized selector sent to instance 0x9cb5c70'
* First throw call stack:
(
0 CoreFoundation 0x029561e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x026d58e5 objc_exception_throw + 44
2 CoreFoundation 0x029f3243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0294650b __forwarding
+ 1019
4 CoreFoundation 0x029460ee _CF_forwarding_prep_0 + 14
5 BoltBeta 0x000e85c5 -[PNSubscribeRequest resourcePath] + 581
6 BoltBeta 0x0006c5dd -[PNBaseRequest HTTPPayload] + 605
7 BoltBeta 0x000eb0b9 -[PNWriteBuffer initWithRequest:] + 169
8 BoltBeta 0x000eafdd +[PNWriteBuffer writeBufferForRequest:] + 141
9 BoltBeta 0x0006be07 -[PNBaseRequest buffer] + 55
10 BoltBeta 0x000d810f -[PNRequestsQueue connection:requestDataForIdentifier:] + 191
11 BoltBeta 0x000869b2 -[PNConnection prepareNextRequestPacket] + 578
12 BoltBeta 0x0007d138 -[PNConnection scheduleNextRequestExecution] + 472
13 BoltBeta 0x00087c78 -[PNConnection writeBufferContent] + 4696
14 BoltBeta 0x0008c40e -[PNConnection handleWriteStreamCanAcceptData] + 190
15 BoltBeta 0x0007e4f8 writeStreamCallback + 1208
16 CoreFoundation 0x0291d266 _signalEventSync + 150
17 CoreFoundation 0x0291d19e _cfstream_solo_signalEventSync + 222
18 CoreFoundation 0x0291cead _CFStreamSignalEvent + 429
19 CoreFoundation 0x0295a7f7 CFWriteStreamSignalEvent + 39
20 CFNetwork 0x00487377 _ZN30CoreWriteStreamCFStreamSupport20coreStreamWriteEventEP17__CoreWriteStreamm + 101
21 CFNetwork 0x0057b02e _ZThn12_N30CoreWriteStreamCFStreamSupport20coreStreamWriteEventEP17__CoreWriteStreamm + 34
22 CFNetwork 0x004872ef _ZN21CoreWriteStreamClient25coreStreamEventsAvailableEm + 51
23 CFNetwork 0x0057c0df _ZN14CoreStreamBase14_callClientNowEP16CoreStreamClient + 49
24 CFNetwork 0x00486f59 _ZN14CoreStreamBase34_streamSetEventAndScheduleDeliveryEmh + 167
25 CFNetwork 0x00486ea9 _ZN14CoreStreamBase12_signalEventEm13CFStreamErrorh + 137
26 CFNetwork 0x00486e18 _ZN14CoreStreamBase28_streamInterface_SignalEventEmPK13CFStreamError + 70
27 CFNetwork 0x00486dca _ZN12SocketStream40dispatchSignalFromSocketCallbackUnlockedEP24SocketStreamSignalHolder + 140
28 CFNetwork 0x00486686 _ZN12SocketStream14socketCallbackEP10__CFSocketmPK8__CFDataPKv + 216
29 CFNetwork 0x00486582 _ZN12SocketStream22_SocketCallBack_streamEP10__CFSocketmPK8__CFDataPKvPv + 74
30 CoreFoundation 0x029161be __CFSocketPerformV0 + 942
31 CoreFoundation 0x028df77f CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
32 CoreFoundation 0x028df1d5 __CFRunLoopDoSources0 + 437
33 CoreFoundation 0x028fc1ae __CFRunLoopRun + 910
34 CoreFoundation 0x028fb9d3 CFRunLoopRunSpecific + 467
35 CoreFoundation 0x028fb7eb CFRunLoopRunInMode + 123
36 GraphicsServices 0x03b235ee GSEventRunModal + 192
37 GraphicsServices 0x03b2342b GSEventRun + 104
38 UIKit 0x01395f9b UIApplicationMain + 1225
39 BoltBeta 0x0000665d main + 141
40 libdyld.dylib 0x02e9f701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException


Furthermore, I am getting a green highlight over the following code and to the right displays "Thread 1: signal SIGABRT:

import <UIKit/UIKit.h>

import "AppDelegate.h"

int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); <-- highlighted
}
}

I do not know what the problem as I don't really have custom code at the moment. The code is coming straight from PubNub. Please help me so I can move on :)

Thank you guys

PubNub library doesn't pass the static clang analyzer test

In PNMessagePostRequest.m around line 155 is the method "signature"

image

The signature variable is never read thus causing the static clang analyzer to come up with the issue.

If you don't know what the analyzer is, in Xcode choose from the menu Product->Analyze.

Problem with catch-up on reconnection

Hello,

We are implementing an apns push mechanism with pubnub.
The following scenario works:

  • Subscribe on a channel.
  • Put the application in the background by pressing home button.
  • Open the app after push is received.
  • The message arrives successfully.

The following doesn't:

  • Subscribe on a channel.
  • Put the device into sleep by pressing sleep button at the top right.
  • Open the app via push notification slider.
  • Message is lost.

We did the following debug session:

  • Subscribe on a channel
  • Put the device into sleep by pressing sleep button at the top right.
  • Open the device via regular slider.

We had additional error logs when we woke up the device compared to when we opened the application from background. The logs told us that the device reconnected with error. Complete logs are attached to this issue below - How can we handle the case so that we are able to retrieve the message that was related to the push. There is only a single message and a time window of between 5-15 seconds so there should not be need for history api.


2013-08-15 20:09:47.117 aProj[2837:907] PNConnection (0x1fd6b690) {ERROR}[CONNECTION::PNMessaginConnectionIdentifier::READ] ERROR OCCURRED (STREAM ERROR OCCURRED)
2013-08-15 20:09:47.120 aProj[2837:907] PNConnection (0x1fd6b690) {ERROR}[CONNECTION::PNMessaginConnectionIdentifier] GOT ERROR: Error Domain=com.pubnub.pubnub Code=103 "PubNub client connection lost connection"
2013-08-15 20:09:47.122 aProj[2837:907] PNReachability (0x1fd5cf80) PubNub services reachability changed [CONNECTED? NO]
2013-08-15 20:09:47.124 aProj[2837:907] PubNub (0x1fd5c0e0) IS CONNECTED? NO (STATE: 5)
2013-08-15 20:09:47.126 aProj[2837:907] AppDelegate (0x1fd22970) willDisconnectWithError: Error Domain=com.pubnub.pubnub Code=103 "PubNub client connection lost connection"
2013-08-15 20:09:47.178 aProj[2837:907] PNConnection (0x1fdbeef0) {ERROR}[CONNECTION::PNServiceConnectionIdentifier::READ] ERROR OCCURRED (STREAM ERROR OCCURRED)
2013-08-15 20:09:47.204 aProj[2837:907] PNConnection (0x1fdbeef0) {ERROR}[CONNECTION::PNServiceConnectionIdentifier] GOT ERROR: Error Domain=com.pubnub.pubnub Code=103 "PubNub client connection lost connection"
2013-08-15 20:09:47.215 aProj[2837:907] AppDelegate (0x1fd22970) didDisconnectFromOrigin: ios.pubnub.com withError
2013-08-15 20:09:47.228 aProj[2837:907] AppDelegate (0x1fd22970) willConnectToOrigin: ios.pubnub.com
2013-08-15 20:09:47.409 aProj[2837:907] PNConnection (0x1fd6b690) {INFO}[CONNECTION::PNMessaginConnectionIdentifier::READ] STREAM OPENED (STREAM IS OPENED)
2013-08-15 20:09:47.411 aProj[2837:907] PNConnection (0x1fd6b690) {INFO}[CONNECTION::PNMessaginConnectionIdentifier::WRITE] STREAM OPENED (STREAM IS OPENED)
2013-08-15 20:09:47.428 aProj[2837:907] PNConnection (0x1fdbeef0) {INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] STREAM OPENED (STREAM IS OPENED)
2013-08-15 20:09:47.430 aProj[2837:907] PNConnection (0x1fdbeef0) {INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] STREAM OPENED (STREAM IS OPENED)
2013-08-15 20:09:47.434 aProj[2837:907] AppDelegate (0x1fd22970) didConnectToOrigin: ios.pubnub.com
2013-08-15 20:09:47.436 aProj[2837:907] AppDelegate (0x1fd22970) willRestoreSubscriptionOnChannels: (
"PNChannel(0x1fdefa50) aProj_server_live_updates"
)
2013-08-15 20:09:48.065 aProj[2837:907] PNConnection (0x1fd6b690) {INFO}[CONNECTION::PNMessaginConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-15 20:09:48.069 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} WILL START REQUEST PROCESSING: <PNTimeTokenRequest: 0x1fd652a0> [BODY: /time/t_f8e87]
2013-08-15 20:09:48.073 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} DID SEND REQUEST: <PNTimeTokenRequest: 0x1fd652a0> [BODY: /time/t_f8e87]
2013-08-15 20:09:48.077 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} WILL START REQUEST PROCESSING: <PNSubscribeRequest: 0x1fdbee90> [BODY: /subscribe/sub-03fb5f82-c733-11e1-9506-85a0cb5e5d6f/aProj_server_live_updates-pnpres,aProj_server_live_updates/s_20af7/0?uuid=7576ad71-bb09-467d-a159-54dcf44b40f7]
2013-08-15 20:09:48.079 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} DID SEND REQUEST: <PNSubscribeRequest: 0x1fdbee90> [BODY: /subscribe/sub-03fb5f82-c733-11e1-9506-85a0cb5e5d6f/aProj_server_live_updates-pnpres,aProj_server_live_updates/s_20af7/0?uuid=7576ad71-bb09-467d-a159-54dcf44b40f7]
2013-08-15 20:09:48.082 aProj[2837:907] PNConnection (0x1fd6b690) {INFO}[CONNECTION::PNMessaginConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-15 20:09:48.191 aProj[2837:907] PNConnection (0x1fd6b690) {INFO}[CONNECTION::PNMessaginConnectionIdentifier::READ] HAS DATA FOR READ OUT (STREAM IS OPENED)
2013-08-15 20:09:48.195 aProj[2837:907] PNResponseDeserialize (0x1fdcc7e0) RAW DATA: t_f8e87([13765865882873156])
2013-08-15 20:09:48.201 aProj[2837:907] PNConnection (0x1fdbeef0) {INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-15 20:09:48.203 aProj[2837:907] PNServiceChannel (0x1fdcbb90) {INFO} WILL START REQUEST PROCESSING: <PNTimeTokenRequest: 0x1fd5b820> [BODY: /time/t_ae96b]
2013-08-15 20:09:48.206 aProj[2837:907] PNServiceChannel (0x1fdcbb90) {INFO} DID SEND REQUEST: <PNTimeTokenRequest: 0x1fd5b820> [BODY: /time/t_ae96b]
2013-08-15 20:09:48.209 aProj[2837:907] PNConnection (0x1fdbeef0) {INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)
2013-08-15 20:09:48.395 aProj[2837:907] PNConnection (0x1fdbeef0) {INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] HAS DATA FOR READ OUT (STREAM IS OPENED)
2013-08-15 20:09:48.400 aProj[2837:907] PNResponseDeserialize (0x1fddc9c0) RAW DATA: t_ae96b([13765865884196669])
2013-08-15 20:09:48.403 aProj[2837:907] PNServiceChannel (0x1fdcbb90) {INFO} RECIEVED RESPONSE:
HTTP STATUS CODE: 200
RESPONSE SIZE: 28
RESPONSE CONTENT SIZE: 268
IS JSONP: YES
CALLBACK METHOD: t
REQUEST IDENTIFIER: ae96b
RESPONSE: (
13765865884196669
)
2013-08-15 20:09:48.406 aProj[2837:907] PNServiceChannel (0x1fdcbb90) {INFO} PARSED DATA: PNTimeTokenResponseParser (0x1fda9b90): <time token: 13765865884196669>
2013-08-15 20:09:48.408 aProj[2837:907] PNServiceChannel (0x1fdcbb90) {INFO} OBSERVED REQUEST COMPLETED: (null)
2013-08-15 20:09:49.315 aProj[2837:907] PNConnection (0x1fd6b690) {INFO}[CONNECTION::PNMessaginConnectionIdentifier::READ] HAS DATA FOR READ OUT (STREAM IS OPENED)
2013-08-15 20:09:49.319 aProj[2837:907] PNResponseDeserialize (0x1fdcc7e0) RAW DATA: s_20af7([[],"13765865893054977"])
2013-08-15 20:09:49.323 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} RECIEVED RESPONSE:
HTTP STATUS CODE: 200
RESPONSE SIZE: 33
RESPONSE CONTENT SIZE: 273
IS JSONP: YES
CALLBACK METHOD: s
REQUEST IDENTIFIER: 20af7
RESPONSE: (
(
),
13765865893054977
)
2013-08-15 20:09:49.325 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} SUBSCRIBE REQUEST RESPONSE:
HTTP STATUS CODE: 200
RESPONSE SIZE: 33
RESPONSE CONTENT SIZE: 273
IS JSONP: YES
CALLBACK METHOD: s
REQUEST IDENTIFIER: 20af7
RESPONSE: (
(
),
13765865893054977
)

CHANNELS: (
"PNChannelPresence(0x1fdf0880) aProj_server_live_updates-pnpres",
"PNChannel(0x1fdefa50) aProj_server_live_updates"
)
REQUEST: <PNSubscribeRequest: 0x1fdbee90>
2013-08-15 20:09:49.328 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} PARSED DATA: PNChannelEventsResponseParser (0x1fdeebb0) <time token: 13765865893054977, events: (null)>
2013-08-15 20:09:49.330 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} UPDATE CHANNELS SUBSCRIPTION
2013-08-15 20:09:49.333 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} WILL START REQUEST PROCESSING: <PNSubscribeRequest: 0x1fdc3ed0> [BODY: /subscribe/sub-03fb5f82-c733-11e1-9506-85a0cb5e5d6f/aProj_server_live_updates-pnpres,aProj_server_live_updates/s_194f6/13765865893054977?uuid=7576ad71-bb09-467d-a159-54dcf44b40f7]
2013-08-15 20:09:49.337 aProj[2837:907] PNMessagingChannel (0x1fdca190) {INFO} DID SEND REQUEST: <PNSubscribeRequest: 0x1fdc3ed0> [BODY: /subscribe/sub-03fb5f82-c733-11e1-9506-85a0cb5e5d6f/aProj_server_live_updates-pnpres,aProj_server_live_updates/s_194f6/13765865893054977?uuid=7576ad71-bb09-467d-a159-54dcf44b40f7]
2013-08-15 20:09:49.341 aProj[2837:907] PNConnection (0x1fd6b690) {INFO}[CONNECTION::PNMessaginConnectionIdentifier::WRITE] READY TO SEND (STREAM IS OPENED)

WiFi -> Cell while in the background

We've discovered a connectivity issue on iOS. It is a possible hang when switching from WiFi to Cell while the app is in the background.

The patch is available here: https://github.com/pubnub/objective-c/tree/hotfix-t191
This patch is forked off the existing 3.5.1 release, and has been tested.

We are currently assembling our 3.5.2 release, estimated for release by end of next week, which will contain this fix, and other enhancements as well.

geremy

asyncLockingOperationInProgress becomes YES when app is back from background

I'm implementing a chat iOS app using pubnub iOS SDK.
I create a channel between two user for a chat room and it works great.
The issue comes up when the user is closing the app into background from chat room with iPhone home button and then opening the app back.

After that the messages are not being sent. During debug I found out that the boolean in PubNub.m - asyncLockingOperationInProgress becomes YES in this case.

Please guide me.

pubnub doesn't auto-reconnect

I have a status-bar OS X application and the application doesn't autoreconnect to PubNub after being in sleep mode over night.

Without investigating the problem yet, I think this has to do with the fact that being a status bar, the SDK in my app doesn't get the right callback/delegate to verify the connection.

3.6.1 Released

A couple bug fixes. 3.6.1 improves reliability for Presence, plus a couple minor bug fixes.

Connection closes after extended period of no use and doesn't reopen automatically.

We are experiencing an issue with the latest pubnub client.

If we open a connection to a pubnub channel, and leave it open for an extended period of time (something like ten minutes or more) it will close and never reopen automatically.

See the following logs from Xcode:

2013-07-27 17:08:03.761 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND
(STREAM IS OPENED)
2013-07-27 17:09:33.918 generic[16731:11303] PNConnection (0x118126d0)
{INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] HAS DATA FOR READ
OUT (STREAM IS OPENED)
2013-07-27 17:09:33.919 generic[16731:11303] PNConnection (0x118126d0)
{INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] NOTHING TO READ
(STREAM CAN'T READ/WRITE DATA)
2013-07-27 17:09:33.919 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" channel stream states: 0 / 3
2013-07-27 17:09:33.919 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" channel stream states: 0 / 0
2013-07-27 17:09:33.919 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" closed all streams
2013-07-27 17:09:33.919 generic[16731:11303] PNConnection (0x118126d0)
{INFO} Notify delegate that "PNServiceConnectionIdentifier" disconnected
2013-07-27 17:10:03.759 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] HAS DATA FOR
READ OUT (STREAM IS OPENED)
2013-07-27 17:10:03.759 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] NOTHING TO READ
(STREAM CAN'T READ/WRITE DATA)
2013-07-27 17:10:03.760 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" channel stream states: 0 / 3
2013-07-27 17:10:03.760 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" channel stream states: 0 / 0
2013-07-27 17:10:03.760 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" closed all streams
2013-07-27 17:10:03.760 generic[16731:11303] PNConnection (0x7231f80)
{INFO} Notify delegate that "PNMessagingConnectionIdentifier" disconnected
2013-07-27 17:10:03.760 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" not configured yet
2013-07-27 17:10:03.760 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" configuration
2013-07-27 17:10:03.760 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" configured
2013-07-27 17:10:03.761 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" connecting
2013-07-27 17:10:03.761 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" opened read stream
2013-07-27 17:10:03.761 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" opened write stream
2013-07-27 17:10:03.761 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" not configured yet
2013-07-27 17:10:03.761 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" configuration
2013-07-27 17:10:03.761 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" configured
2013-07-27 17:10:03.761 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" connecting
2013-07-27 17:10:03.762 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" opened read stream
2013-07-27 17:10:03.762 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" opened write stream
2013-07-27 17:10:03.762 generic[16731:11303] PNServiceChannel (0x118125c0)
{INFO} Destroyed
2013-07-27 17:10:03.762 generic[16731:11303] PNMessagingChannel
(0x7221180) {INFO} Destroyed
2013-07-27 17:10:03.789 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] STREAM OPENED
(STREAM IS OPENED)
2013-07-27 17:10:03.789 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] STREAM OPENED
(STREAM IS OPENED)
2013-07-27 17:10:03.789 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::WRITE] READY TO SEND
(STREAM IS OPENED)
2013-07-27 17:10:03.789 generic[16731:11303] PNConnection (0x118126d0)
{INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] STREAM OPENED
(STREAM IS OPENED)
2013-07-27 17:10:03.789 generic[16731:11303] PNConnection (0x118126d0)
{INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] STREAM OPENED
(STREAM IS OPENED)
2013-07-27 17:10:03.789 generic[16731:11303] PNConnection (0x118126d0)
{INFO}[CONNECTION::PNServiceConnectionIdentifier::WRITE] READY TO SEND
(STREAM IS OPENED)
2013-07-27 17:11:03.870 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] HAS DATA FOR
READ OUT (STREAM IS OPENED)
2013-07-27 17:11:03.870 generic[16731:11303] PNConnection (0x7231f80)
{INFO}[CONNECTION::PNMessagingConnectionIdentifier::READ] NOTHING TO READ
(STREAM CAN'T READ/WRITE DATA)
2013-07-27 17:11:03.870 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" channel stream states: 0 / 3
2013-07-27 17:11:03.870 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" channel stream states: 0 / 0
2013-07-27 17:11:03.871 generic[16731:11303] PNConnection (0x7231f80)
{INFO} "PNMessagingConnectionIdentifier" closed all streams
2013-07-27 17:11:03.871 generic[16731:11303] PNConnection (0x7231f80)
{INFO} Notify delegate that "PNMessagingConnectionIdentifier" disconnected
2013-07-27 17:11:03.877 generic[16731:11303] PNConnection (0x118126d0)
{INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] HAS DATA FOR READ
OUT (STREAM IS OPENED)
2013-07-27 17:11:03.877 generic[16731:11303] PNConnection (0x118126d0)
{INFO}[CONNECTION::PNServiceConnectionIdentifier::READ] NOTHING TO READ
(STREAM CAN'T READ/WRITE DATA)
2013-07-27 17:11:03.878 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" channel stream states: 0 / 3
2013-07-27 17:11:03.878 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" channel stream states: 0 / 0
2013-07-27 17:11:03.878 generic[16731:11303] PNConnection (0x118126d0)
{INFO} "PNServiceConnectionIdentifier" closed all streams
2013-07-27 17:11:03.878 generic[16731:11303] PNConnection (0x118126d0)
{INFO} Notify delegate that "PNServiceConnectionIdentifier" disconnected

3.5.2b Crash in error parsing

Connecting to a channel like so:

[PNChannel channelWithName:response[@"channel"] shouldObservePresence:YES]

This used to subscribe fine. Now the response is this:

HTTP STATUS CODE: 200
CONNECTION WILL BE CLOSE? YES
RESPONSE SIZE: 126
RESPONSE CONTENT SIZE: 371
IS JSONP: YES
CALLBACK METHOD: lv
REQUEST IDENTIFIER: 46d9e
RESPONSE: {
    error = 1;
    message = "Cannot use API on channel name ending with -pnpres.";
    service = Presence;
    status = 400;
}

Which crashes the entire app in PNError.m : 81

if ([errorMessage rangeOfString:@"Presence"].location != NSNotFound) {

I understand this isn't the current version, but this worked up until yesterday, when it began crashing in our production app.

Crashes in -[PubNub handleApplicationDidEnterBackgroundState:]

We've been getting a large number of crashes that look like the following (it is the #1 crash in our app, by far):

Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x3a947626 objc_msgSend + 5
1 Tophatter 0x00122c11 -PubNub handleApplicationDidEnterBackgroundState:
2 CoreFoundation 0x2fd381f1 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 12
3 CoreFoundation 0x2fcac57f _CFXNotificationPost + 1718
4 Foundation 0x30696a3d -[NSNotificationCenter postNotificationName:object:userInfo:] + 76
5 UIKit 0x32614dcd -[UIApplication _handleApplicationSuspend:eventInfo:] + 908
6 UIKit 0x32596ca5 -[UIApplication handleEvent:withNewEvent:] + 880
7 UIKit 0x32596871 -[UIApplication sendEvent:] + 72
8 UIKit 0x325facc9 _UIApplicationHandleEvent + 616
9 GraphicsServices 0x34bd0aed _PurpleEventCallback + 608
10 GraphicsServices 0x34bd06d7 PurpleEventCallback + 34
11 CoreFoundation 0x2fd40ab7 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 34
12 CoreFoundation 0x2fd40a53 __CFRunLoopDoSource1 + 346
13 CoreFoundation 0x2fd3f227 __CFRunLoopRun + 1398
14 CoreFoundation 0x2fca9f4f CFRunLoopRunSpecific + 522
15 CoreFoundation 0x2fca9d33 CFRunLoopRunInMode + 106
16 GraphicsServices 0x34bcf663 GSEventRunModal + 138
17 UIKit 0x325f516d UIApplicationMain + 1136
18 OurApp 0x000c25d3 main (main.m:3)

We are using the latest commit, 64448a9.

Any idea what might be going on?

subscription time out after unsubscribe

i have an ios app which for ever room a user enters theirs is a pubnub subscription created with the room id, when the user leaves the room an unsubscribe call is made.

my issue is that if i enter the room,,, chat a bit, exit it and then enter the same room again, the newest subscription call fails due to timeout

handleOriginLookupTimer caches a lot of calls

It seems that the handleOriginLookupTimer will 'leak' around 1.9k every 10 seconds to the cache, that is never cleared out. You can check this by running the demo app, connecting to the server, and tapping the mark heapshot every 10 seconds. What you will see is that after a while, there are a whole lot of ~ 1.9k heap growths with around 32-33 objects that are all CF... objects.
Adding a simple cache clearing line after the sendSynchronousRequest will help alleviate this issue.

diff --git a/iOS/iPadDemoApp/pubnub/libs/PubNub/Network/PNReachability.m b/iOS/iPadDemoApp/pubnub/libs/PubNub/Network/PNReachability.m
index ee4fdcc..bf457d5 100644
--- a/iOS/iPadDemoApp/pubnub/libs/PubNub/Network/PNReachability.m
+++ b/iOS/iPadDemoApp/pubnub/libs/PubNub/Network/PNReachability.m
@@ -476,6 +476,7 @@ void PNReachabilityCallback(SCNetworkReachabilityRef reachability __unused, SCNe
             NSMutableURLRequest *timeTokenRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[PNNetworkHelper originLookupResou
             timeTokenRequest.timeoutInterval = kPNReachabilityOriginLookupTimeout;
             NSData *downloadedTimeTokenData = [NSURLConnection sendSynchronousRequest:timeTokenRequest returningResponse:&response error:&requestErr
+            [[NSURLCache sharedURLCache] removeCachedResponseForRequest:timeTokenRequest];

             dispatch_async(dispatch_get_main_queue(), ^{

No clear way to grant or revoke presence access on a channel

Looking over the code, I see no clear way to grant or revoke presence access on a particular channel. I added code in PNChangeAccessRightsRequest object that appended the -pres channel if that channel was set up to observe presence but it appears the web API does not support multiple channels in an access rights change request. My short-term fix was to create a PNChannel object for the presence channel and grant access using that object. Not sure how or if it will affect the PNChannel cache since it gets separated from it's non-presence channel. Not too big of a deal but figured I'd open an issue for it.

sendMessage: toChannel: stops working after device goes to sleep

If I try sending a message before my device goes to sleep (when I've just installed the app), everything works fine. However if the app goes to sleep due to inactivity and I try to send a message again, it won't send and no error message is provided.

If I let it go to sleep again and awake it, the message will be sent. I'm not quite sure what's happening and despite having a PNObservationCenter set up and the various message delegate methods, nothing seems to get called.

Please add notification about possible data lost.

Currently if application is for some longer time in background, when app starts again PubNub receives disconnected error like:

GOT ERROR: Domain=NSPOSIXErrorDomain; Code=57; Description="Unknown error."; Reason="Unknown error reason."; Fix suggestion="There is no known solutions."; Associated object=(null) (CFNetwork error code: 57 (Domain: NSPOSIXErrorDomain); connection should be close? YES)

From testing i was able to find out that when this occurs PubNub automatically connects back, but some of the events could been lost.

Would like to have some flag on PubNub or in config to be able to disable automatic reconnection in that situation, or at least be notified so that i could perform some additional steps.

Krzysztof

PNMessage.channel is null

Howdy,
I've noticed that the channel comes through as null in objective-c. This is if sent from dev console or php.

"PNMessage (0xb580c90): <message: {\n    channel = BWods7Zpzx;\n    guestInitiated = 1;\n    guestName = Jimbo;\n    status = 0;\n    waitId = dS2etPy2Ef;\n}, date: PNDate (0xb580ed0) <date: 2013-06-06 18:47:44 +0000; time token: 13705444640769226>, channel: (null)>"

Reconnection Issue #2

Hello,
I've got problem with reconnection using 3.4
I'm Testing using simulator, in configuration i have autoReconnectClient=YES

When i disconnect wifi, and connect soon after pubnub does not reconnect at all

If i try to manually listen to connection back and call PubNub disconnect, and then connect again it does not work as well.

Did bit research myself and here what i come with so far

With manual connecting, it seams to be stack with state Disconnecting, so fix for that could be to include PNPubNubClientStateDisconnecting in following if:

// Check whether PubNub client was just created and there
                    // is no resources for reuse or not
                    if ([self sharedInstance].state == PNPubNubClientStateCreated ||
                        [self sharedInstance].state == PNPubNubClientStateDisconnected || {

As for auto reconnecting, think it is stack because it tries to connect again just before it is notified from reachability. It goes to handleConnectionErrorOnNetworkFailure, but does not set state to disconnected on error, so maybe setting state to disconnected on error in that method would be fix.

Best Regards
Krzysztof

PubNub retrieving history is really slow

Hello,

Thanks for the great service. We are using it for the 2nd chatting app already and its great!

The main issue I'm having with pubnub that sometimes getting the chat history is really slow. We are showing the last chat message on the initial screen of the app (under username, just like most other chatting apps do). So for opening that screen we will have to ask for the history for all the users you chat with (we have separate channel for each conversation).

The problem is that it does not make big difference if we are asking for history of channel with the limit 1 to retrieve only the last message or requesting the full history.

So what is the best way to do the task described to make that load as fast as facebook does for instance.

Thanks,
Narek

README typo

In Finishing up configuration (Common to Manual and CocoaPods setup), PNAppDelegate should be just AppDelegate (for most applications)

Main Thread blocked for a long time.

This method blocks on the main thread occasionally

  • (SCNetworkConnectionFlags)synchronousStatusFlags

In PNReachability.m

According to the readme.txt of Apple's Reachability app/project SCNetworkReachabilityGetFlags should never be called synchronously on the main thread:

"The Reachability sample demonstrates the asynchronous use of the SCNetworkReachability API. You can use the API synchronously, but do not issue a synchronous check by hostName on the main thread. If the device cannot reach a DNS server or is on a slow network, a synchronous call to the SCNetworkReachabilityGetFlags function can block for up to 30 seconds trying to resolve the hostName. If this happens on the main thread, the application watchdog will kill the application after 20 seconds of inactivity."

Pubnub library won't reconnect on connection loss (using 3G)

Hello, we're developing an iOS app that uses pubnub for realtime chat. We use ios.pubnub.com as origin

The problem is, that if we use 3G or EDGE, everything works fine until one of the devices experiences some problems with the network (or you switch the mobile data off manually).

Once the network is up on that device, it won't reconnect automatically. We've monitored the channel via pubnub console - no messages are recieved after the moment network was up again.

It usually reconnects in about 5-15 minutes, but not always.

Note: while pubnub library doesn't send anything, all other network activity is okay, so it's seems to be related with pubnub reconnection to server.

This problem doesn't usually occur with a stable wifi connection.

P.S. Is there any workaround for this? Can we somehow detect that pubnub cannot connect and reinitialize it?

3.5.3 yanked

If you happen to have used the briefly unveiled 3.5.3, stop using it immediately, and switch to the latest version immediately! We've since fixed a bug that could interrupt subscriber operations when toggling the app background <-> foreground.

Reconnection Issue

I have a use case where user subscribes to only a single channel which is private to the user. So user A subscribes to channel 'A' and user B subscribes to channel 'B'.

I am using default configuration to initialize PubNub. If I put the app in background and lock the phone , then come back to app, the connection is lost. This only happens on actual device and not on simulator and there is no attempt to reconnect.

Wont PubNuB library try to reconnect on its own , because kPNShouldAutoReconnectClient seems to be YES

Also do you have any pointers on handling app switching / putting app to background

When is the mentioned update for aps / APNs handling going to come out?

  1. My current app sends a lot of additional info along with a message, and because currently anything after "aps" key is included in the push payload, it easily goes over 256 bytes and does not send pushes. When I tried putting the "aps" key as anything other than the first key, it simply doesn't send.
  2. Is this change going to be exclusively server side? Would it require a SDK update?

Referencing the change mentioned in: http://www.pubnub.com/docs/objective-c/iOS/tutorial/apple-push-notification.html
"As of today, when Mobile Push Gateway for APNs scans a messsage payload for APNs content, anything in the "aps" key will be sent, as well any key that follows"
"This behavior will change in a future release so that only content contained in the "aps" tag is sent to APNS."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.