android - titanium studio push notifications closing the app -


i trying show push notifications in android app, developed titanium studio, getting alert unfortunately app closed after clossing, 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 register push! ' + e.error);         }     });  } catch(e) {     alert('error :', e); }  // enable push notifications device // save device token subsequent api calls function devicetokensuccess(e) {     cloudpush.enabled = true;     devicetoken = e.devicetoken; }  function devicetokenerror(e) {     alert('failed register 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 push notifications in tray when app not running cloudpush.addeventlistener('trayclicklaunchedapp', function(evt) {     ti.api.info('tray click launched app (app not running)'); }); // triggered when push notifications in tray when app running cloudpush.addeventlistener('trayclickfocusedapp', function(evt) {     ti.api.info('tray click focused app (app running)'); });  

what wrong doing 1 suggest me, how resolve isssue

thanks in advace

try changing code follows

var cloudpush = require('ti.cloudpush'); try {      cloudpush.retrievedevicetoken({         success : function devicetokensuccess(e) {             deviceid = e.devicetoken;             cloudpush.enabled = true;             ti.api.info(deviceid);             ti.app.properties.setstring('deviceid', '' + deviceid);         },         error : function devicetokenerror(e) {             alert('failed register push! ' + e.error);         }     });  } catch(e) {     alert('error :' + e); }  // 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 push notifications in tray when app not running cloudpush.addeventlistener('trayclicklaunchedapp', function(evt) {     ti.api.info('tray click launched app (app not running)'); }); // triggered when push notifications in tray when app running cloudpush.addeventlistener('trayclickfocusedapp', function(evt) {     ti.api.info('tray click focused app (app running)'); });  

i have removed callback methods code. , please make sure you're using latest cloudpush module. please check tiapp.xml, if have selected '*' module version, change latest number (3.2.3 me)


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -