an-dynamic-cancel

I’ve basically stopped using Tasker’s built-in notification creation actions altogether, because AutoNotification simply does it better. Very often I use the option to make a notification persistent to make sure it stays in my notification bar until I’ve seen it (i.e. it can’t be dismissed with the “clear all” button or swiping it off), and this requires that you run the AutoNotification Cancel action to actually clear it.

I tend to add a button to the notification to do this, and then make a new profile that triggers on the message sent by that button and then cancels the notification out. This adds a few extra steps each time, but luckily there’s a way to make sure you only need one profile that will cancel any persistent notification dynamically, and without interfering with other notifications than the one that’s clicked.

The trick here lies in that AutoNotification uses the same messaging system as other AutoApps. that means you can use parameters and commands like in AutoRemote, as well as AutoNotification-versions of the variables that creates.

To set it up, create a profile with AutoNotification’s context, and make the Message Filter cancel=:=. In the task, add the AutoNotification Cancel action, and in the ID field, use %ancomm, AutoNotification’s equivalent of %arcomm/%avcomm. Save the profile, and that part’s done. Now, next time you need to add a button in an AutoNotification to cancel the notification, simply make the message that button sends cancel=:=ID, where ID is the unique ID you gave that notification.

This way, the ID is passed to the profile that cancels the notification, and as such, you don’t need individual profiles for each notification. It also speeds up the process of creating a persistent AutoNotification, as you don’t need to create that extra profile.