Reputation: 733
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?
Upvotes: 1
Views: 2984
Reputation: 1504
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.
Upvotes: 0
Reputation: 7962
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();
Upvotes: 0
Reputation: 3579
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.
Upvotes: 1