Search code examples
androidfirebasenotificationslogoutfirebase-notifications

NotificationListenerService in Android Marshmallow


I need to clear my applications notifications when the user logout's from the app. I am not generating notifications using NotificationBuilder my notifications are directly generated from the server for the app. I am able to to clear my notifications on user logout in android lolipop and below. But for marshmallow when user gives notification access permission from settings I don't receive any notifications for marshmallow. Need some help regarding this. I am receiving notifications from Firebase.


Solution

  • All you need to do is:

    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancelAll();
    

    No need for notification access and all the other logics.