Surfer on the fall
Surfer on the fall

Reputation: 733

How to delete push notification

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

Answers (3)

Parth Kapoor
Parth Kapoor

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

shimi_tap
shimi_tap

Reputation: 7962

If i'm able to understand what you mean, you have 1 option :

  1. 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

Aman Gautam
Aman Gautam

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

Related Questions