This is the Pusher module for Titanium Mobile applications on iOS.
Please check the documentation folder for instructions on how to use it.
You should also download the latest version of the module and follow the instructions here to install.
- version 1.8 [ link ]
Before you can build the module, you have to update the dependencies using git:
$ git submodule init
$ git submodule update
Then, assuming you have the latest Titanium Mobile, Xcode (currently 4.4) and the iOS SDK (currently 5.0), you can build simply by entering
$ ./build.py
If it fails, the number one cause is a missing path to a Titanium SDK. Please edit
the titanium.xcconfig
file and adjust the path and versions of your SDK.
You can also run the included example app by entering,
$ titanium run
The work on the 1.0 version was 100% sponsored by the awesome guys at Red Robot Labs, Inc., thanks!
The main difference to the old versions was a complete rewrite of the module, to be as much compatible as possible with the JavaScript Pusher API. Because of that, we've changed some things:
-
you should stop using
addEventListener
andremoveEventListener
. It will simply not work anymore! -
All the callbacks receive the data directly (like the JS API) and not an object with some Titanium garbage. Example:
// old channel.addEventListener('event', function(event) { alert("DATA IS " + event.data); }); // new channel.bind('event', function(data) { alert("DATA IS " + data); });
The main difference when you want to port your code is initialization and global configuration.
Pusher.channel_auth_endpoint = 'http://....';
var pusher = new Pusher(applicationKey, options);
pusher.subscribe(...)
var pusher = require('com.0x82.pusher');
pusher.channel_auth_endpoint = 'http://.....';
pusher.setup(applicationKey, options);
pusher.subscribe(...)
There are a few quirks on other parts too:
- you cannot use
channel.members.get("1")
because it seems thatget
is somewhat a reserved word on Titanium. UsegetMember("1")
instead.
Other than this, this module should have 100% compatibility with the Javascript counterpart! So you can just follow the official Pusher JS documentation here.