Page 1 of 1

Notification action

Posted: 08 Oct 2017 14:14
by yogi108
Hi,
Just want to now if an action in an notification is set to an flow how to know the trigger?
For this one flow I always see beside the variables action_number and action_text the trigger 'short cut flowname'.
So I can't differentiate between the shortcut pressed or the notification action pressed - via trigger.
At the moment I use this 2 variables to differentiate.
If I make a new flow and set the action to the new flow name I get the trigger 'manual'.
Regards

Re: Notification action

Posted: 08 Oct 2017 17:23
by Desmanto
I don't quite understand what you mean. You mean one of the action in the notification is set to "Execute Flow" XYZ, and what is the trigger if you press that action?

If that what you mean, the trigger is "Manual". While if your XYZ flow has another separate trigger using "Shortcut XYZ", then when you trigger it by tapping the shortcut, the trigger will be "Shortcut XYZ". You can then use Expression in flow XYZ to check if

Code: Select all

trigger == "Shortcut XYZ"
If true, trigger is from shortcut. If false, trigger is from tapping action in notification.

However if you execute the flow from other flow (not from action in notification), the trigger will be trigger of the calling flow. So if you have another flow with trigger "Period Timer: 5 minutes", and it has action "execute flow" XYZ, the trigger passed to XYZ is the same : "Period Timer: 5 minutes". (will evaluate to false if you use expression above)

Re: Notification action

Posted: 09 Oct 2017 11:24
by yogi108
Hi Desmanto,
Here is the working test flow:
http://automagic4android.com/flow.php?i ... c2398cd332

You have to create your own shortcut for testing.
Tap the shortcut, the notification will be created.
Tap the 'test action' in the notification and see the trigger.
Start the flow manually and see the trigger...

Thanks as always for your input,
Regards

Re: Notification action

Posted: 09 Oct 2017 16:51
by Desmanto
You create a loop using the action to call the flow which create the notification again. It is better to split it to separate flow.

I have tested it, and it seems any action executed from notification will inherit the trigger of the flow which create the notication. In your case, manual will remain manual all the time until you remove the notification; Shortcut will remain shortcut. I think this should go to request subforum, where notification action should have default trigger value called "Notification Click", just like widget has "Widget Click". That way, you can differentiate between the shortcut trigger and notification click trigger.

Meanwhile, before it is implemented, you probably really need to design your flow that way. I forgot to add this yesterday. You can set the action of the notication click to Send Broadcast, not Execute flow. You have to add new trigger to the same flow, General Broadcast. Later, use expression to check the trigger. Shortcut will remain shortcut, but notification click will be become trigger "General broadcast". Look at my index, Execute Automagic flow with parameter. You can use broadcast, com.automagic.notificationclick (example) in both send broadcast and trigger general broadcast. You can also pass parameter, and check the parameter to know the click come from which one (there can be 3 actions at notification).

Re: Notification action

Posted: 09 Oct 2017 17:50
by yogi108
Hi,

I very often try to keep all action in one flow, then decide through the trigger which branch to follow.

But you got the point, the trigger notification action should have a proper name, hopefully for the next release.

I also tried the broadcast solution you mentioned, it's a little complex but got it to work with your infos above.

Thanks again,
Regards

Re: Notification action

Posted: 10 Oct 2017 09:48
by Martin
Hi,

Automagic already provides the number of the clicked action (in variable action_number) and the text/label of the clicked action (in variable action_text) to the executed action (resp. the executed flow when using an action Execute Flows).
You can probably just use variable action_text instead of variable trigger in the condition.

Regards,
Martin

Re: Notification action

Posted: 10 Oct 2017 10:22
by yogi108
Hi Martin,

This solution I got through the debug condition also.

Would be nice if notification could behave like widget.

Thanks a lot,
Regards

Re: Notification action

Posted: 10 Oct 2017 10:34
by Desmanto
Ah, I see. I replace the debug dialog from yogi108's flow with toast, so I don't pay attention to this variable. It can be done then.

@yogi108 : You only need extra expression to check if the action_number or action_text exist or not. Something like

Code: Select all

action_number == null
If true (the variable not available), then the trigger is not from notification click. If false (action_number exist), then trigger must be from one of the notification click action.

You can remove the previous send broadcast/general broadcast pair then, since it is not needed anymore.