Remove notifications in QML

My tasklist app publishes Notifications for tasks with certain properties via qml.

When the app or phone crashes, these notifications are left in place.

Is there a way to remove all notifications published by my app?

You already cleanup your notifications in Component.onDestruction callback… I am worry, that you cannot do something more when your application crashes. In C++ code you can register own abort signal handler, fork new process from it and try to solve situation… But it seems to me like a overkill. I may suggest to focus to avoiding crashes :slight_smile:

Yes, when the app exits clean, removeAll cleans the notifications and my app doesn’t crash :wink:.

But sometimes all apps get killed by the system (when it runs out of memory?) or the device reboots itself, then the notifications are left in the notification area.

Not a big deal, but would be nice to solve.

Do you want to clese automatically when crashed? This is not possible. But you can save https://sailfishos.org/develop/docs/nemo-qml-plugin-notifications/qml-nemo-notifications-notification.html/#replacesId-prop values to close it later.
Or you can fix crash of your application :slight_smile:

4 Likes

Saving the ids should work, thanks. :+1: