I created a capacitor plugin that enables to watch notifications being posted or removed. Read the documentation on GitHub.
Unfortunately, the plugin does not support running in the background. This is a conscious design choice, so that you are able to choose or implement your preferred method of “running in the background” yourself. The plugin capacitor-persistent-notification could help you with such an endeavor.
Install the plugin using:
npm i capacitor-notificationlistener
npx cap sync
And register it using add(NotificationListenerPlugin.class)
in your MainActivity.java
like in the following example:
// ... code ...
import ch.asinz.capacitornotificationlistener.NotificationListenerPlugin;
// ... code ...
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Put it here!
add(NotificationListenerPlugin.class);
}});
// ... code ...
Please visit the documentation for further information.