Flutter Awesome Notification couldn't bind a method to action button

2,221

You should create a event stream and listen to events like that:

    AwesomeNotifications().actionStream.listen((event) {
      print('event received!');
      print(event.toMap().toString());
      // do something based on event...
    });
Share:
2,221
arincgurkan
Author by

arincgurkan

Updated on December 01, 2022

Comments

  • arincgurkan
    arincgurkan over 1 year

    I'm developing an app which needs to answer the notifications. I can display the button when I received the notification. However, I couldn't bind any method to it. Here is my code:

    Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message)  async {
      await Firebase.initializeApp();
        AwesomeNotifications().createNotification(
              content: NotificationContent(
                  id: 10,
                  channelKey: 'basic_channel',
                  title: 'Simple Notification',
                  body: 'Simple body'),
              actionButtons: [
                NotificationActionButton(
                    label: 'TEST',
                    enabled: true,
                    buttonType: ActionButtonType.Default,
                    key: 'test',
                    )
              ]);
        print("Background message service");
      }
    

    Thank you for your helps!

    • Benyamin Beyzaie
      Benyamin Beyzaie almost 3 years
      any solution on that?
  • alperefesahin
    alperefesahin over 1 year
    outdated for the new version...