0

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?

Surfer on the fall
  • 721
  • 1
  • 8
  • 34

3 Answers3

1

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.

Community
  • 1
  • 1
Aman Gautam
  • 3,549
  • 2
  • 21
  • 25
0

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();

shimi_tap
  • 7,822
  • 5
  • 23
  • 23
0

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.

Parth Kapoor
  • 1,494
  • 12
  • 23