android - Titanium Alloy Push Notification Subscribed But Listener Not firing Up -


i need make push notification listener, code below , runs perfect till subscription , dashboard confirms subscribed successfully, problem occurs receiver.

alloy.globals.serviceaddress = "my service address"; ti.api.info("1"); var cloudpush = require('ti.cloudpush'); var cloud = require("ti.cloud"); var devicetoken = null;  loginuser(); // flow starts here function loginuser() {   cloud.users.login({     login: 'user',     password: 'password'   }, function(e) {     if (e.success) {       var user = e.users[0];       //    alert("loggin successfully");       getdevicetoken();     } else {       alert("error2*** :" + e.message);       //ti.api.info('error ')     }   }); }  function getdevicetoken() {    if (ti.platform.android) {     cloudpush.debug = true;     cloudpush.focusapponpush = false;     cloudpush.enabled = true;     cloudpush.showappontrayclick = true;     cloudpush.showtraynotification = true;     cloudpush.singlecallback = true;     cloudpush.singlecallback = true;     cloudpush.retrievedevicetoken({       success: devicetokensuccess,       error: devicetokenerror     });   } }  // enable push notifications device // save device token subsequent api calls function devicetokensuccess(e) {   devicetoken = e.devicetoken;   alert(e.devicetoken);   subscribetochannel(devicetoken); }  function devicetokenerror(e) {   alert('failed register push notifications! ' + e.error); }  // process incoming push notifications function subscribetochannel(devicetoken) {    // subscribes device 'news_alerts' channel   // specify push type either 'android' android or 'ios' ios   cloud.pushnotifications.subscribetoken({     device_token: devicetoken,     channel: 'vision', //'you_app',     type: ti.platform.name == 'android' ? 'android' : 'ios'   }, function(e) {     if (e.success) {       alert('subscribed');       sendnotification(devicetoken);     } else {       // indicator.visible = false;       alert('subscribe error:\n' + ((e.error && e.message) || json.stringify(e)));     }   }); }  function sendnotification(to_devicetoken) {   alert('sendnot');   cloud.pushnotifications.notifytokens({     channel: 'my cannel',     to_tokens: to_devicetoken,     payload: 'welcome push notifications'   }, function(e) {     if (e.success) {       alert('success send');     } else {       alert('send error:\n' +         ((e.error && e.message) || json.stringify(e)));     }   }); } 

when add event-listener push notifications doesn't fire however, client saying connected.

<!-- language: lang-js --> cloudpush.addeventlistener('callback', function (evt) {     alert('rec');     alert("notification received: " + evt.payload); }); cloudpush.addeventlistener('trayclicklaunchedapp', function (evt) {     ti.api.info('tray click launched app (app not running)'); }); cloudpush.addeventlistener('trayclickfocusedapp', function (evt) {     ti.api.info('tray click focused app (app running)'); }); 

ps. have searched , read related threads like one

i attaching log make clarify subscription , notification send working push notification log , connected clients

solved compiling titanium api level 4.1.1.v20151203143424 cloudpush module version 3.2.1 migrated titanium 6.0.0.v20160202173231 cloudpush module version 3.4.1 , set see in this pic


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -