2

I have implemented Push using this plugin.

Now when I have multiple notifications with different notId, and I tap on one of them, the event handler is called but the other notifications vanish from the notifications tray.

This particular issue seems to be open at the Github page of the older version of the same plugin.

Following is my code:

  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);*/
    });

I tried commenting the setApplicationIconBadgeNumber in the bottom, but didnt help.

Any fix/workaround for this?

Lakshay Dulani
  • 1,710
  • 2
  • 18
  • 45
  • http://stackoverflow.com/questions/37967944/tapping-on-one-notification-clears-all-the-other-notification-from-the-same-app doesnt help i guess – Lakshay Dulani Jun 22 '16 at 12:25

1 Answers1

0

This is because the option clearNotifications is default to true for Android, which clears all the notifications. Set it to clearNotifications:false for Android, and it will work fine.

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

Lakshay Dulani
  • 1,710
  • 2
  • 18
  • 45