点击一个通知会清除来自同一应用程序的所有其他通知 - Phonegap Plugin Push

Tapping on one notification clears all the other notification from the same app - Phonegap Plugin Push

我已经使用这个 plugin 实现了 Push。

现在,当我有多个不同 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,但没有帮助。

有任何 fix/workaround 吗?

这是因为选项 clearNotifications 默认为 true for Android,这会清除所有通知。 将它设置为 clearNotifications:false for Android,它将正常工作。

https://github.com/phonegap/phonegap-plugin-push/issues/1015 https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions