The simple and plain event profile from Event → UI → Notification → an app doesn't get triggered if the user (for which Tasker is running) is in background because "Notifications for other users do not appear until they are active." Any such profile never gets triggered when I'm running a secondary user in foreground and Tasker is running in the primary user's environment.
I've the Notification access to Tasker under Settings → Notification manager already enabled. So that's definitely not the roadblock here.
I hoped for finding the notification log's location and running Tasker's file modification event profile on the file, with certain tweaks I might add, but well, I ended up asking a separate question for that. See Where does Lollipop stores notification log?
So, what is the best course of action to consider here?
Please note that I can always periodically check the output of
notification service using
dumpsys or the function(s) mentioned here by Bo Lawson but periodically means that I'm certain not to be able to execute a task exactly when the notification arrives. I can definitely decrease the time period for periodical checks but that would cause too much CPU usage for every check and battery output is limited always.
If you're still wondering what my goal is: A notification for an app shows up (consider any app) for the primary user running in background. Tasker detects it and writes some text into a file.
Sounds easy! Right.
Oh, and if the goal can be achieved using some other means, then feel free to suggest them, with details.
I'm using a OnePlus One running COS12 (Xposed Framework installed) and several Android 5.1 ROMs. Tasker's version is 4.7u3.