I'm using GCM for an android app client. The problem is: sometimes the user reads the notification on the webapp, instead of the android app. I'd like to delete the notification in the android device if it happens. How could I do it with Phonegap?
3 Answers
Well GCM Notification is just a message. You need to check the code that created the notification to see the ID of the notification. You can cancel the notification on the notice bar though. When the user reads the notification on the web app, you can send another GCM message to device telling it to cancel the previous notification. This is how you can cancel the previous notification.

- 1
- 1

- 3,549
- 2
- 21
- 25
If i'm able to understand what you mean, you have 1 option :
Send a new notification to your application which will let you know that a notification was viewed and then in your GCM listener simply do :
((NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE)).cancelAll();

- 7,822
- 5
- 23
- 23
-
what if I'm using Phonegap/cordova? – Surfer on the fall Jun 12 '14 at 12:07
-
Then how are you sending notification to the application ? if it's a Phonegap inner implementation you need to override it – shimi_tap Jun 12 '14 at 12:43
Create a Notification
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
Cancel a Notification
notificationManager.cancel(NOTIFICATION_ID);
The thing is you should keep NOTIFICATION_ID = some Primary key that identifies the record. Use same key as NOTIFICATION_ID.

- 1,494
- 12
- 23