79822381

Date: 2025-11-17 14:02:42
Score: 0.5
Natty:
Report link

Notifications obtained from NotificationManager does not have any data. To distinguish them it is possible to send AndroidNotification.tag tr FCM see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification

fun Context.notificationManager() =
    getSystemService(NOTIFICATION_SERVICE) as NotificationManager

...

context.notificationManager()
    .activeNotifications
    .onEach { statusBarNotification ->
        // Api should send processedNotificationsUuids as tag
        // https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification
        if (statusBarNotification.tag in processedNotificationsUuids) {
           context.notificationManager()
                  .cancel(statusBarNotification.tag,statusBarNotification.id)
        }
    }
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Vouskopes