Help with handling notification

nirax

New member
I have a macro which sets a notification. This notification should invoke a macro upon clicking. That macro should have the text of the notification available to it for further processing.

The first image is the macro which creates the notification. Macro name = zzz test macro 1.1

It's notification handler is shown in the second image.

This notification displays a text "test1 : test2". It invokes a macro "zzz test macro 1.2". As you can see, it tries to use the built-in variable "{notification}", but it didn't work.


How do I make the text "test1 : test2" available to macro1.2 when it is invoked by the notification?

EDIT :: The above is only a minimum working example. In actual deployment, the first macro will be triggered by messages, GeoFence, location, cell connection, wifi or even other notification sent via HTTP. The notification sent by the first macro will display something about the trigger and other information which is dynamic and differ from notification to notification. By the time any notification is clicked, several newer notification might already be displayed. The action undertaken by this click should be specific to only the current notification being handled. This is why a global variable will not work.


Any help would be greatly appreciated.
 

Attachments

  • Screenshot_20240124_171243_1.jpg
    Screenshot_20240124_171243_1.jpg
    103.5 KB · Views: 12
  • Screenshot_2024_0124_171344.jpg
    Screenshot_2024_0124_171344.jpg
    88.6 KB · Views: 11
  • Screenshot_2024_0124_171315.jpg
    Screenshot_2024_0124_171315.jpg
    56.3 KB · Views: 11
Last edited:

hsurB

Well-known member
Its probably because to use magic text from 3rd screen you need to use trigger notification recieved/cleared for exemple. Otherwise macrodroid has no idea which notification's text to use.
There are some possible solutions for your macro like using variable in action display notification and then the same in pop up message or using clear notification as a trigger instead invoking it by clicking but I am not sure what exactly is your macro supposted to be used for so I can't really tell if that helps in your case
 

nirax

New member
The trigger notification recieved will invoke macro1.2 as soon as the notification gets displayed.

That is not desirable. Macro1.2 should get invoked only when the notification is clicked.

Please copy this simple macro in your setup and if you get it working, please let me know
 

hsurB

Well-known member
Remake macro thats invoked by clicking notification to check text on screen(read screen content action), perform text manipulations to save notification's text into variable and use this variable in pop up message
 

hsurB

Well-known member
Yeah and you can't do it this way cause its too late to read notification but clicking notification clears it and trigger notification cleared can use notification text magic text so you can't use it too in your case DEAR?
 

Qarboz

Well-known member
I have a macro which sets a notification. This notification should invoke a macro upon clicking. That macro should have the text of the notification available to it for further processing.

The first image is the macro which creates the notification. Macro name = zzz test macro 1.1

It's notification handler is shown in the second image.

This notification displays a text "test1 : test2". It invokes a macro "zzz test macro 1.2". As you can see, it tries to use the built-in variable "{notification}", but it didn't work.


How do I make the text "test1 : test2" available to macro1.2 when it is invoked by the notification?

Any help would be greatly appreciated.
Copy your notification string of macro 1.1 in a string global variable and use this in macro 1.2
 

nirax

New member
By the time this notification is pressed, several new notifications might be sent by the first macro, after all it gets triggered in the real world not by empty trigger but by location or messages or other notifications.

Each of those notifications will have different texts.

When I do get to see and click one of those notifications, several other notification might have updated the global variable. I would not get the desired action.
 
Last edited:

Qarboz

Well-known member
By the time this notification is pressed, several new notifications might be sent by the first macro, after all it gets triggered in the real world not by empty trigger but by location or messages or other notifications.

Each of those notifications will have different texts.

When I do get to see and click one of those notifications, several other notification might have updated the global variable. I would not get the desired action.
You should explain better what you want to achieve, otherwise you may get wrong suggestions with related waste of everyone's time
 

RSF

Well-known member
Invoke an Action Block instead of a Macro in your notifications' configurations (you can pass parameters to action blocks, but cannot pass them to macros; see the "Configure Input/Output Params" button in the notification configuration example below, which appears when you select an action block to handle the tap). The action block can then use those values to do whatever you want, based on which notification data was sent, and multiple notifications can be configured to have their own independent parameters, even if they're all displayed at the same time.

Example:
See attached action block, which just displays the parameters passed to it, but shows how to define parameters that can be configured in the macro below. The action block needs to be defined first, so that you can specify it in the macro's Notification action.

Then, see this example notification's configuration in a macro -- calling an Action Block vs. a macro :
Notif_Config1.jpg
and how you can populate the parameters by tapping that "Configure..." button:
Notif_Config2.png
 

Attachments

  • Respond_to_notification_tap.ablock
    2.3 KB · Views: 2

nirax

New member
Invoke an Action Block instead of a Macro in your notifications' configurations (you can pass parameters to action blocks, but cannot pass them to macros; see the "Configure Input/Output Params" button in the notification configuration example below, which appears when you select an action block to handle the tap). The action block can then use those values to do whatever you want, based on which notification data was sent, and multiple notifications can be configured to have their own independent parameters, even if they're all displayed at the same time.

Example:
See attached action block, which just displays the parameters passed to it, but shows how to define parameters that can be configured in the macro below. The action block needs to be defined first, so that you can specify it in the macro's Notification action.

Then, see this example notification's configuration in a macro -- calling an Action Block vs. a macro :
View attachment 8360
and how you can populate the parameters by tapping that "Configure..." button:
View attachment 8361
I had already tried using the action option. Since I couldn't get it working, I had posted the problem in this thread https://www.macrodroidforum.com/index.php?threads/action-launch-via-notification.6199/

I tried your example too. The action is never launched by the notification. Though it can be tested and it works as expected but it is not launched by the notification. It doesn't even register on the system log
 

RSF

Well-known member
It definitely works to invoke an Action Block from a notification -- I have a number of examples like that. So I wonder if your Notification action configuration, or Action Block definition, may need to be adjusted.
Can you post your macro and action blocks (not screenshots, but export and post the actual macro/action block files)?
 

nirax

New member

Attachments

  • zzz_test_action.ablock
    1.1 KB · Views: 1
  • zzz_test_macro.macro
    1.1 KB · Views: 3
  • Test_notif_launch.macro
    3.4 KB · Views: 3

RSF

Well-known member
I imported the "Test Notif Launch" macro and the "zzz test action" action block, and it all worked as expected for the Notification that calls the action block:
  • The notification appeared in my Notification Bar on Android
  • When I swiped down the Notification Bar, to see the full notification, and tapped on that notification,
    • The notification was dismissed by Android
    • The action block was called, and the Popup message was displayed at the bottom of my screen
I wonder if the Popup message disappears too quickly for it to be obvious that the Action Block got called? Try displaying a Dialog instead of a Popup; that'll force a response before it goes away. See the edited action block, attached.

Also: what version of MacroDroid are you running?
 

Attachments

  • zzz_test_action.ablock
    2.1 KB · Views: 1

nirax

New member
I imported the "Test Notif Launch" macro and the "zzz test action" action block, and it all worked as expected for the Notification that calls the action block:
  • The notification appeared in my Notification Bar on Android
  • When I swiped down the Notification Bar, to see the full notification, and tapped on that notification,
    • The notification was dismissed by Android
    • The action block was called, and the Popup message was displayed at the bottom of my screen
I wonder if the Popup message disappears too quickly for it to be obvious that the Action Block got called? Try displaying a Dialog instead of a Popup; that'll force a response before it goes away. See the edited action block, attached.

Also: what version of MacroDroid are you running?
Still no luck.

I am using v5.40.4 Pro version of macrodroid

I am also attaching the system log screenshot as the original macro is run-tested. As you can see, the notification which contains the action is logged here when it is launched. However nothing gets logged about it when it is tapped. The macro launching notification gets logged as expected.

1706593797239.jpeg
 
Last edited:

RSF

Well-known member
I'm stumped. It works fine on my phone (and Chromebook). My log shows the action block getting invoked:
Screenshot 2024-01-30 9.09.53 AM.png

Couple suggestions:
  1. Try adding a button in the notification, and have that button invoke the action block -- see if that works:
    1706635705068.png

  2. Report a bug (MacroDroid home screen; three-lines menu at top left of screen; Troubleshooting menu option; Report a Bug link at the bottom of that screen
 
Top