Appcelerator Titanium iOS Push Notification

To integrate Pushwoosh into your Appcelerator Titanium iOS application you need to do simple following steps: 1. Download the following script and place it in your Resources folder (the folder where app.js is located): 2. Include the following line in your app.js. Replace ‘YOUR_PUSHWOOSH_APP_CODE’ with your Pushwoosh application code from the control panel.

Ti.include('pushwoosh.js'); PushWoosh.appCode = 'YOUR_PUSHWOOSH_APP_CODE';
3. Registering and handling push notifications. On start of the application call the following function:
Ti.Network.registerForPushNotifications({ types : [Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND], success : function(e) { var deviceToken = e.deviceToken;'successfully registered for apple device token with ' + e.deviceToken); PushWoosh.register(function(data) { Ti.API.debug("PushWoosh register success: " + JSON.stringify(data)); }, function(e) { Ti.API.warn("Couldn't register with PushWoosh: " + JSON.stringify(e)); }); }, error : function(e) { Ti.API.warn("push notifications disabled: " + JSON.stringify(e)); }, callback : function(e) { Ti.API.warn("push message received: " + JSON.stringify(e)); //send stats to Pushwoosh about push opened PushWoosh.sendPushStat(; var a = Ti.UI.createAlertDialog({ title : 'New Message', message : //message : JSON.stringify( //if you want to access additional custom data in the payload });; } });
4. Expert mode on! **Tags** (please note the device have to be registered with Pushwoosh before calling this method):
PushWoosh.setTags({alias:"device1"}, function(data) { Ti.API.debug("PushWoosh sendTags success: " + JSON.stringify(data)); },function(e) { Ti.API.warn("Couldn't setTags with PushWoosh: " + JSON.stringify(e)); });
**Stats:** call this function on start to track application open stat
//record stats for app open with Pushwoosh PushWoosh.sendAppOpen();
call this function in your push notifications handler to track opened push notifications count:
//send stats to Pushwoosh about push opened PushWoosh.sendPushStat(;
**Auto badges** In order to make auto badges work, every time you change badge value in your app call the following function:
//notifies Pushwoosh about current badge value PushWoosh. sendBadge(5);
If you have any problems, check out Appcelerator Titanium push notifications sample app: [](
NOTE: iOS Simulator is not able neither to subscribe nor receive push notifications.