libPusher now supports event triggering
As part of my implementation, I've introduced a new, higher-level API in the form of
PTPusherChannel. It sacrifices some flexibility (by using a shared API key, secret and app ID) for the sake of ease of use and attempts to mirror the way the Ruby Pusher client gem works. All of the lower-level API detailed in my original blog post is still available.
To use it, you first need to configure
PTPusher with your credentials; a good place to do this is in your
applicationDidFinishLaunching app delegate method:
Once you have done this, creating new channels is easy:
Note that the
channel methods returns an autoreleased
PTPusherChannel instance so you will need to retain it and release it when you are finished with it.
To trigger a new event, simply call the
triggerEvent:data: method; the
data parameter can be a string or any Objective-C object that can be serialized as JSON, such as an array or dictionary:
In addition to being able to trigger events,
PTPusherChannel offers an alternative means of receiving events on that channel using a delegate:
Here is a small screencast of the included sample app triggering and handling its own events.
For more details, check out the updated README on GitHub and take a look at the sample app.