【问题标题】:Flutter Awesome Notification couldn't bind a method to action buttonFlutter Awesome Notification 无法将方法绑定到操作按钮
【发布时间】:2021-06-20 22:39:21
【问题描述】:

我正在开发一个需要回复通知的应用。我可以在收到通知时显示按钮。但是,我无法将任何方法绑定到它。这是我的代码:

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");
  }

感谢您的帮助!

【问题讨论】:

  • 有什么解决办法吗?

标签: flutter firebase-notifications flutter-notification


【解决方案1】:

你应该创建一个事件流并监听这样的事件:

    AwesomeNotifications().actionStream.listen((event) {
      print('event received!');
      print(event.toMap().toString());
      // do something based on event...
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    • 2011-07-22
    • 1970-01-01
    • 2011-04-01
    • 1970-01-01
    相关资源
    最近更新 更多