How to implement notification aggregation

My application displays event notifications, and I'm looking for a way to create notification aggregation. Meaning, I would like to show 4 notifications, but if the fifth comes, I would like to collect all the notifications and show only one general notification.

Is there a way to find out how many live notifications I have? Can I approach this notification and cancel them?

Thanks!

+4
source share
1 answer

According to android design tips, you should add up your notifications. Therefore, you should avoid displaying multiple notifications for the same application.

You can add your notifications using

NotificationManager.notify(ID, notification) , where you specify the same identifier for each notification.

You can check the docs on how to implement it.

For your case

 Is there a way to know how many live notifications i have - No 

But you can track notifications using the general settings, where you store the notification ID and delete it when the user clicks on the note

 Is it possible to approach these notification and cancel them? - Yes 

You can cancel the notification using the cancel(int id) method, where you pass the identifier of the notification you want to delete.

Thus, you can use this method to achieve what you want, but it is advisable to combine all the notifications.

0
source

Source: https://habr.com/ru/post/1498123/


All Articles