Reputation: 36674
I want to push a notification to the user every X minutes.
However if there already exist an unread notification,
I want to delete it and replace it with a new one. How can I delete?
How can I check how many unread notification my app has already pushed?
Upvotes: 0
Views: 117
Reputation: 40218
To replace an existing notification with a new one you should simply post a notification with the same id, this behavior is mentioned in the documentation of NotificationManager
's notify() method. If you want to just remove a notification, call cancel()
providing the id you used to start it.
Regarding counting the number of notifications your app has sent, I think the best solution would be to just store a counter and increment it once a notification has been sent.
Upvotes: 1