【发布时间】:2015-10-08 05:37:24
【问题描述】:
看起来在过去几周 Ionic 推送通知发生了一些变化。
老路
$ionicPush.register({
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) {
// Handle new push notifications here
alert(notification);
return true;
}
});
新方式
$ionicPush.init({
"debug": true,
"onNotification": function(notification) {
var payload = notification.payload;
console.log(notification, payload);
},
"onRegister": function(data) {
console.log(data.token);
});
$ionicPush.register();
您可以看到最新版本中的不同代码阻止了 iOS 具有声音和其他功能。我尝试在$ionicPush.init 中添加回canPlaySound: true,但没有成功。
如何取回 ios 的所有通知功能列表?
更新
正确答案
$ionicPush.init({
"debug": true,
"onNotification": function(notification) {
var payload = notification.payload;
console.log(notification, payload);
},
"onRegister": function(data) {
console.log(data.token);
},
"pluginConfig": {
"ios": {
"badge": true,
"sound": true
},
"android": {
"iconColor": "#343434"
}
}
});
【问题讨论】:
标签: android ios cordova push-notification ionic