I am sending a notification with GCM to an Android device and it is arriving correctly, but there is one case when the notifications are displaying after being dismissed. The steps to reproduce:
- Open the application that starts the service to receive notifications.
- Send gcm message with a
notification
payload. - Dismiss the notification by swiping left/right this notification. It is also valid to click it if it has an
action_click
element. - Open tasks and close the current application.
- Open the application again. When the GCM service starts again, it receives the previously dismissed notification.
My code is the most basic one from the example provided by google using the GcmListenerService
. Just set the permissions, put the services in the manifest and let google display the notification for you. I am being called twice in the onMessageReceive
on the service with the same data when the scenario provided happened.
This is the notification payload I am sending to GCM:
{
collapseKey: 'push',
delayWhileIdle: true,
timeToLive: 3600,
data: undefined,
notification: {
body: 'test message 2 updated',
title: 'Notification',
icon: 'myicon'
},
contentAvailable: false
}
EDIT:
- I am using the
play-services-gcm:7.8.0
version, but also tested with 7.5 - I can repeat the process 5 times, after that, the notifications gets dismissed forever.