【发布时间】:2016-09-07 12:05:14
【问题描述】:
当应用程序在后台或屏幕被锁定时,我能够发送推送表单 apps.ionic.io 和邮递员,但在应用程序打开时无法发送通知。 我的代码是 在运行中
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);
});
在控制器中
$ionicPush.register( {
canShowconsole.log: true, //Can pushes show an console.log on your screen?
canShowAlert: true, //Can pushes show an alert on your screen?
canSetBadge: true, //Can pushes update app icon badges?
canPlaySound: true, //Can notifications play a sound?
canRunActionsOnWake: true, //Can run actions outside the 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);
});
【问题讨论】:
-
我也遇到了同样的问题,你找到解决办法了吗?如果你发现了什么,请分享。
-
不走运,我目前没有在工作。我什么时候工作再告诉你,
-
也面临同样的问题。 @AnujGupta 你找到什么了吗?
-
@VinothKumar 你试过了吗?
标签: android ionic-framework push-notification google-cloud-messaging