You should use NotificationListenerService for this purpose (To catch Notification of application NotificationListenerService is another option like Accessibility Service).
Where onNotificationRemoved gives StatusBarNotification into parameter. By reading this param you can get all information about notification.
You can read NotificationListenerService-Example for more details.