By Technical Support
#10 To integrate BlukPush into your Appcelerator Titanium iOS application you need to do simple following steps:
1. Download the sample and place the BlukPush.js script in your Resources folder (the folder where app.js is located): Generic Push Module Script
2. Include the following line in your app.js. Replace ‘YOUR_BLUKPUSH_APP_CODE’ with your BlukPush application code from the control panel.
Code: Select allvar BlukPush = require('BlukPush/BlukPush');
BlukPush.appCode = ‘YOUR_APP_CODE’;

3. Registering and handling BlukPush notifications. On start of the application call the following function:
Code: Select allvardeviceToken = null;
// Check if the device is running iOS 8 or later
   if( ==
   "iPhone OS"&&parseInt(Ti.Platform.version.split(".")[0]) >= 8) {
      functionregisterForPush() {
         success : deviceTokenSuccess,
         error : deviceTokenError,
         callback : receivePush
// Remove event listener once registered for BlukPush
// Wait for user settings to be registered before registering for BlukPush
// Register notification types to use
    } else{
// For iOS 7 and earlier
// Specifies which notifications to receive
   types : [Ti.Network.NOTIFICATION_TYPE_BADGE,
   success : deviceTokenSuccess,
   error : deviceTokenError,
   callback : receivePush
// Process incoming BlukPush notifications
  functionreceivePush(e) {
//alert('Received push: ' + JSON.stringify(e));
  Ti.API.warn("BlukPush message received: " + JSON.stringify(e));
     var a = Ti.UI.createAlertDialog({
     title : 'New Message',
     message :,
     buttonNames : [ 'Close']
//message :JSON.stringify( //if you want to access additional
                                  //custom data in the payload
  a.addEventListener('click', function(e) {
  if (e.index == 0) {
 // Save the device token for subsequent API calls
    functiondeviceTokenSuccess(e) {
    deviceToken = e.deviceToken;'successfully registered for
    apple device token with '+ e.deviceToken);
    BlukPush.register(deviceToken, function(data) {
    Ti.API.debug("BlukPush register success: "+ JSON.stringify(data));
    BlukPush.setTags({alias:"device1"}, function(data) {
    Ti.API.debug("BlukPushsendTags success: "+ JSON.stringify(data));
    },function(e) {
    Ti.API.warn("Couldn't setTags with BlukPush: "+ JSON.stringify(e));
    function(e) {
    Ti.API.warn("Couldn't register with BlukPush: "+ JSON.stringify(e));
    functiondeviceTokenError(e) {
    alert('Failed to register for BlukPush notifications! '+ e.error);
    Ti.API.warn("BlukPushnotifications disabled: "+ JSON.stringify(e));

4. Expert mode on!
Please note that the device has to be registered with BlukPushbefore calling this method:
Code: Select allBlukPush.setTags({alias:"device1"}, function(data) {
Ti.API.debug("BlukPushsendTags success: "+ JSON.stringify(data));
},function(e) {
Ti.API.warn("Couldn't setTags with BlukPush: "+ JSON.stringify(e));

Call this function on start to track application open stat
Code: Select all//record stats for app open with BlukPush

Call this function in your push notifications handler to track opened push notifications count:
Code: Select all//send stats to BlukPush about push opened