0

I work with Notification GCM in cordova android apps. when the application is running in background and a notification came it is displayed in the status bar of the device. when more than two notifications are displayed in this status bar, I tap on first notification (displayed in the status bar), the application opens and it displays the notification message, when I tap on the second notification all of the remaining notifications(in the status bar) vanish. In this fonction, when I tap on the notification, the part (! e.foreground) runs.

function onNotificationGCM(e) {

  switch( e.event )
   {
    case 'message':


        if (e.foreground)
        {   
            // playAudio('http://oringz.com/oringz-uploads/sounds-1068-the-calling.mp3');
            navigator.notification.beep(1);
            msgNotification(e.payload.message);
            $("#toastContainer").dxToast('instance').show();
            var notif={message:e.payload.message};
            popovernotifListe.push(notif);
            nbrnotif(nbrnotif()+1);

        }
        else if (!e.foreground)
        {

             if (e.coldstart) {
                    console.log("App was not running and user clicked on notification");
            } else {
                console.log("App was running and user clicked on notification");
            }
            msgNotification(e.payload.message);
            $("#toastContainer").dxToast('instance').show();
            nbrnotif(nbrnotif()+1);
            var notif={message:e.payload.message};
            popovernotifListe.push(notif);

        }
        break;

        case 'error':
          console.log('GCM error = '+e.msg);
        break;

        default:
          console.log('An unknown GCM event has occurred');
        break;
}

}

Cœur
  • 37,241
  • 25
  • 195
  • 267
msuser
  • 1
  • 4
  • 2
    I'm not downvoting this, but you *really* should improve your question. What would you like to happen? Could you show us some code? – jmm Jun 16 '15 at 16:41
  • I did it ( better explained with code ) – msuser Jun 17 '15 at 09:30
  • Does this [answer](http://stackoverflow.com/a/29437083/1761793) help? – Ajoy Jun 19 '15 at 17:59
  • thank you for your help but this doesn't solve the problem, when I touched the second notification in the status bar, (when I have many), the others vanish in the status bar – msuser Jun 23 '15 at 14:29

1 Answers1

3

If the notification ID is not sent from your server, each notification is created with an ID 0.

To fix this problem, you will have to set the notification ID for each notification you create. You can set the notification ID by sending a parameter notID from the server, with each notification, which will be used to create a notification.

Ajoy
  • 1,838
  • 3
  • 30
  • 57