【问题标题】:How to get NotificationActionButton input data with flutter?如何通过颤振获取 NotificationActionButton 输入数据?
【发布时间】:2022-01-09 23:24:21
【问题描述】:

我正在尝试获取通知操作按钮数据。也就是用户填写输入动作的时候,我得到他输入的数据。

就这样。

我正在使用 awesome_notifcations 颤振包。

这是我的函数,用于创建带有评论输入操作的新通知

Future<void> create({
    required String key,
    required String title,
    required String body,
    required String bigPicture,
  }) async {
    await _notiff.createNotification(
        content: NotificationContent(
          id: DateTime.now().millisecondsSinceEpoch.remainder(10),
          channelKey: key,
          title: title,
          body: body,
          bigPicture: bigPicture,
          notificationLayout: NotificationLayout.BigPicture,
        ),
        actionButtons: [
          NotificationActionButton(
              buttonType: ActionButtonType.InputField,
              enabled: true,
              label: "Comment",
              key: "COMMENT_BUTTON_KEY")
        ]);
  }

这里我只是想获取用户的评论。

怎么做?

【问题讨论】:

    标签: android flutter push-notification android-notifications


    【解决方案1】:

    您是否需要创建侦听器才能获得这样的新通知:

    AwesomeNotifications().actionStream.listen(
        (ReceivedNotification receivedNotification){
    
            Navigator.of(context).pushNamed(
                '/NotificationPage',
                arguments: {
                    // your page params. I recommend you to pass the
                    // entire *receivedNotification* object
                    id: receivedNotification.id
                }
            );
    
        }
    );
    

    PD:您是否需要替换为您的数据,此信息在文档中(5. 如何显示本地通知)

    【讨论】:

    • 不!我想在用户提交时获取输入动作的数据。
    • 查看whatsapp消息的例子。用户在不打开消息的情况下响应消息。我想收到“不出现在线回复”的消息(如下图所示)。
    猜你喜欢
    • 1970-01-01
    • 2021-09-06
    • 2021-07-24
    • 2019-11-01
    • 2019-04-20
    • 2022-10-06
    • 2019-11-21
    • 2021-02-16
    • 2021-10-15
    相关资源
    最近更新 更多