我已使用此plugin实现了推送。
现在,当我有多个不同notId
的通知,并点击其中一个时,会调用事件处理程序,但其他通知会从通知托盘中消失。
此特定问题似乎在相同插件的旧版本的Github页面上打开。
以下是我的代码:
var push = PushNotification.init({
"android": {"senderID": "XXXXXXX" ,"icon": "ic_transey1",
"iconColor": "grey"},
"ios": {"alert": "true", "badge": "true", "sound": "true"}, "windows": {}
});
push.on('registration', function (data) {
console.log('device token ',data.registrationId);
window.localStorage.setItem("UserDeviceID", data.registrationId);
});
push.on('error', function (e) {
console.log(e);
});
push.on('notification', function (data) {
console.log('notification event');
navigator.notification.confirm(
data.message,
function (buttonIndex) {
onConfirm(buttonIndex, data);
},
data.title,
['Dismiss','Ok']
);
/* at first I thought setApplicationIconBadgeNumber is causing the issue,
but commenting the below code didnt help either */
/*push.setApplicationIconBadgeNumber(function() {
console.log('success in clearin');
}, function() {
console.log('error');
}, 0);*/
});
我尝试在底部评论setApplicationIconBadgeNumber
,但没有帮助。
对此有何修复/解决方法?
答案 0 :(得分:0)
这是因为Android的选项clearNotifications
默认为true
,它会清除所有通知。
https://github.com/phonegap/phonegap-plugin-push/issues/1015 https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions