I am trying to show push notifications in android app, developed by titanium studio, my getting alert with unfortunately app is closed after this my is clossing, my code is
try {
CloudPush.retrieveDeviceToken({
success : function deviceTokenSuccess(e) {
deviceID = e.deviceToken;
Ti.API.info(deviceID);
Ti.App.Properties.setString('deviceid', '' + deviceID);
},
error : function deviceTokenError(e) {
alert('Failed to register for push! ' + e.error);
}
});
} catch(e) {
alert('Error :', e);
}
// Enable push notifications for this device
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
CloudPush.enabled = true;
deviceToken = e.deviceToken;
}
function deviceTokenError(e) {
alert('Failed to register for push notifications! ' + e.error);
}
// Process incoming push notifications
CloudPush.addEventListener('callback', function(evt) {
//alert(evt.payload);
var alertNotification = Titanium.UI.createAlertDialog({
title : 'app',
message : evt.data.alert,
cancel : 1,
buttonNames : ['OK']
});
alertNotification.show();
});
// Triggered when the push notifications is in the tray when the app is not running
CloudPush.addEventListener('trayClickLaunchedApp', function(evt) {
Ti.API.info('Tray Click Launched App (app was not running)');
});
// Triggered when the push notifications is in the tray when the app is running
CloudPush.addEventListener('trayClickFocusedApp', function(evt) {
Ti.API.info('Tray Click Focused App (app was already running)');
});
what was the wrong I am doing will any one suggest me, how to resolve this isssue
thanks in advace