1

Title. Near identical code for both projects in their respective templates. Both projects successfully creates a PubNub object (the logger shows up in the command line), however only one of them (iOS Single View App) receives a response through func client(client: PubNub!, idReceiveMessage message: PNMessageResult!). Why does the project in the Command Line template not work?

Min Tseng
  • 181
  • 1
  • 2
  • 5
  • 1
    I would need a little more information about what you are trying to accomplish to answer the questions. If I understand the statement above, you have 2 different projects but the same code...can you post code samples? in a nutshell, you need to have a listener registered with the SDK for didReceiveMessage a member of PNObjectEventListener to fire off, there are several other variables at play...more information is needed. Command line template? – Frederick Brock Aug 11 '15 at 18:25

2 Answers2

1

Asynchronous operations don't work automatically for command line tools. They will work by default for a Mac OS X app or an iOS app.

Have you seen the advice in this post about manually entering the run loop?

Keep command line tool alive

Community
  • 1
  • 1
gurooj
  • 2,100
  • 4
  • 21
  • 25
0

Just for clarification. Command line applications are very different than IOS apps. IOS/Mac OSX provides a different runtime environment that abstracts away the complexity of writing your own runloop to manage things such as asynchronous calls. The PubNub IOS SDK is built for those environments, not for command line applications.

If you want to build a command line app using PubNub I'd strongly recommend using a different SDK (maybe node or ruby, mono c-sharp) that would require far less infrastructure work on your part.

http://www.pubnub.com/developers

Frederick Brock
  • 116
  • 1
  • 3