android - Ionic push notification is not working if app is open -


i able send push form apps.ionic.io , postman when app on background or screen locked not able send notification when app open. code in run

    var io = ionic.io();             var push = new ionic.push({                "onnotification": function(notification) {             alert('received push notification!');           },            "pluginconfig": {                     "android": {                         "icon": "ic_stat_icon"                     }                 },           "debug": true         });  push.register(function(token) {       console.log("registered");       console.log("device token:",token.token);     }); 

and in controller

 $ionicpush.register( {     canshowconsole.log: true, //can pushes show console.log on screen?     canshowalert: true, //can pushes show alert on screen?     cansetbadge: true, //can pushes update app icon badges?     canplaysound: true, //can notifications play sound?     canrunactionsonwake: true, //can run actions outside app,     onnotification: function(notification) {        console.log(notification);      // handle new push notifications here      alert('received push notification!');      return true;    }         }).then(function(t) {     return $ionicpush.savetoken(t);   }).then(function(t) {     console.log('token saved:', t.token);   }); 

try thing in app.js or controller file.

$rootscope.$on('cloud:push:notification', function(event, data) {       var msg = data.message;       console.log(msg);       // alert(msg.title + ': ' + msg.text);        var alertpopup = $ionicpopup.alert({             title: msg.title,             template: msg.text.tostring()         });      }); 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -