phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

How do I clear single notification? #2120

Closed clzola closed 6 years ago

clzola commented 6 years ago

I am using Ionic and I would like to know Is there any way to clear single notification. I know there is this method: push.clearAllNotifications but that clears all notifications.

For example I send three notifications with notId set to 20, 21, 22 and now, when user opens application normally, not via notification, and goes to screen A and there use can see a list of items. Then he may open one of the items, and I should clear notification with id 20, but keep 21 and 23...

However I have also tried with this plugin: https://ionicframework.com/docs/native/local-notifications/

and when I call this.localNotifications.clear(20) nothing happens but this.localNotifications.clearAll() works...

jcesarmobile commented 6 years ago

It's not possible

clzola commented 6 years ago

Can you tell me why it is not possible? Maybe I could write a pull request for android then... Because, few months ago I have created native android application, and I was using this code for creating notification:

notificationManager.notify(EVENT_NOTIFICATION_TAG, Integer.parseInt(event.get("gd_id")), notificationBuilder.build());

and to clear it I would use this:

notificationManager.cancel(EventNotificationService.EVENT_NOTIFICATION_TAG, mEvent.id);

jcesarmobile commented 6 years ago

On iOS it's not possible because Apple doesn't provide a way of doing it. On Android it's not implemented, so it's not possible. If you know how to implement it, send a PR but don't forget to document it and say that is Android only

lock[bot] commented 6 years ago

This thread has been automatically locked.