title: Flutter - Can we execute code Without opening the app by clicking on Notification Button?
body: <p>I'm getting Notification when the app is <strong>open/closed</strong>,</p>
  <p>Step:- <strong>killed</strong> the app(<em>don't level on the background</em>), once you get a notification, click on any button of notification and perform a code(business logic) in it <strong>without opening an app</strong>?</p>
  <p>Note:- I'm using an <strong>awesome_notifications</strong> PUB to get Action Button on Notifications.</p>
  <p>to get notification in any case</p>
  <pre><code>```socketNotification(BuildContext context) async {
      try {
        notificationSocketBackService.clearListeners();
      } catch (error) {
        print(&quot;error :-=&gt; $error&quot;);
      }
      String userid = &quot;${await PreferenceHelper().getUserID()}&quot;;
      notificationSocketBackService = IO.io(
          socketURL,
          IO.OptionBuilder()
              .setTransports(['websocket']) // for Flutter or Dart VM
              .setQuery({&quot;user_id&quot;: &quot;$userid&quot;})
              .setExtraHeaders({'Upgrade': 'WebSocket', 'Connection': 'Upgrade'})
              .enableAutoConnect()
              .setReconnectionDelay(1)
              .enableReconnection()
              .build());
  
      notificationSocketBackService.on(&quot;checkConnection&quot;, (data) {
        isConnectedWithSocket = true;
      });
  
      notificationSocketBackService.on(
        &quot;notificationToClient&quot;,
        (data) async {
          Map notificationData;
          try {
            notificationData =
                jsonDecode(data.toString().replaceAll(&quot;node&quot;, '&quot;node&quot;'));
          } catch (e) {
            print(&quot;CounterService object e :-=&gt; $e&quot;);
            notificationData = {&quot;error&quot;: &quot;No notifications found&quot;};
          }
          if (jsonEncode(notificationData).contains(&quot;error&quot;)) {
            return;
          } else {
            List&lt;NotificationActionButton&gt; actionButtons = [];
            Map notificationPayload = notificationData[&quot;node&quot;];
            if (notificationPayload[&quot;type&quot;] == &quot;FlyingLike&quot; &amp;&amp;
                notificationPayload[&quot;flyingLikeStatus&quot;] == &quot;Requested&quot; &amp;&amp;
                notificationPayload.containsKey(&quot;flyingLikeID&quot;) &amp;&amp;
                notificationPayload[&quot;flyingLikeID&quot;] != null &amp;&amp;
                notificationPayload[&quot;flyingLikeID&quot;] != &quot;&quot;) {
              //
              actionButtons.add(
                NotificationActionButton(
                  key: Constants.accept,
                  label: Constants.accept,
                ),
              );
              actionButtons.add(
                NotificationActionButton(
                  key: Constants.reject,
                  label: Constants.reject,
                ),
              );
            } else if (notificationPayload[&quot;type&quot;] == &quot;Like&quot;) {
              //
              actionButtons.add(
                NotificationActionButton(
                  key: Constants.like,
                  label: Constants.like,
                ),
              );
            } else if (notificationPayload[&quot;type&quot;] == &quot;Match&quot;) {
              if (appLifecycleState != AppLifecycleState.resumed) {
                return;
                //
                actionButtons.add(
                  NotificationActionButton(
                    key: Constants.viewMatch,
                    label: Constants.viewMatch,
                  ),
                );
                return;
              }
              return;
            } else {
            }
            String description = &quot;&quot;;
            if (notificationPayload[&quot;type&quot;] == &quot;Match&quot;) {
              description = notificationPayload[&quot;description&quot;] +
                  &quot; to &quot; +
                  notificationPayload[&quot;sender&quot;][&quot;firstName&quot;];
            } else {
              description = notificationPayload[&quot;description&quot;];
            }
            await AwesomeNotifications().createNotification(
              content: NotificationContent(
                id: notificationPayload[&quot;id&quot;].hashCode,
                channelKey: 'basic_channel',
                title: '${notificationPayload[&quot;title&quot;]}',
                body: '${description}',
                notificationLayout: NotificationLayout.Default,
                payload: {&quot;node&quot;: &quot;${data[&quot;node&quot;]}&quot;},
                createdSource: NotificationSource.Firebase,
              ),
              actionButtons: actionButtons,
            );
          }
        },
      );
    }
  ```
  </code></pre>
  <p>to perform a execute on click oF any button of notification
  below code run at home screen were we get loaded all data of user which need</p>
  <pre><code>AwesomeNotifications().actionStream.listen((notification) {
            if (notification.channelKey == 'basic_channel' &amp;&amp; Platform.isIOS) {
              AwesomeNotifications().getGlobalBadgeCounter().then(
                    (value) =&gt;
                        AwesomeNotifications().setGlobalBadgeCounter(value - 1),
                  );
            }
  
            getButtonKeyPressedAction(notification);
          });
  </code></pre>