Skip to content

[firebase_messaging] I can't remove incoming Firebase notifications programmatically #766

@kroikie

Description

@kroikie

I have an incoming Firebase notification coming to my phone and if the user does not tap on it and the user re-opens the app, I want the Android notification to be removed programmatically by tag received from the notification payload.

I have used the Firebase_messaging "^1.0.3" Flutter plugin and the MessageHandler for incoming message works.
Inspecting Firebase Notification from StatusBarNotification I noticed the id_notification is always 0 while the tag is the one sent.

To remove the notification from StatusBar programmatically I have used a platform channel:

private boolean removeNotification(String tag, int idNotifica) {
boolean result = false;
NotificationManager notifManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notifManager.cancel(tag, idNotifica);
//notifManager.cancelAll(); --- it doesn't work too
result = true;
return result;
}

but the notification can't be removed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions