gpt4 book ai didi

android - 带有操作按钮和图像的 Flutter 本地通知

转载 作者:行者123 更新时间:2023-12-04 23:40:43 28 4
gpt4 key购买 nike

我想用 Firebase 消息推送这种类型的通知。现在是我使用 https://pub.dev/packages/flutter_local_notifications 的普通通知的时候了。这个包。但我没有看到有一种方法可以添加操作按钮。以及我想在 45 秒后删除此通知或使用另一条 firebase 消息。我也在为 android 和 ios 开发这个应用程序。如果我的问题不清楚或需要更多信息,请随时发表评论。
enter image description here
我在 Stackoverflow 上看到了一个类似的问题。

  • Flutter local notification with action buttons
  • Notification with action buttons
  • 最佳答案

    ticket 中所述,flutter_local_notification 尚未支持通知操作按钮.您可能要考虑使用 awesome_notifications同时插件,因为它支持通知按钮。
    要使用操作按钮显示通知,只需使用


    void _showNotificationWithButton() {
    AwesomeNotifications().createNotification(
    content: NotificationContent(
    id: 10,
    channelKey: 'basic_channel',
    title: 'Simple Notification',
    body: 'Simple body'),
    actionButtons: <NotificationActionButton>[
    NotificationActionButton(key: 'yes', label: 'Yes'),
    NotificationActionButton(key: 'no', label: 'No'),
    ],
    );
    }
    然后,您可以通过在 NotificationActionButton 上添加图标属性来添加操作按钮的图标。图标应该是 Assets 中映射的图像的字符串资源。
    要监听 Action Button 按下,请使用 actionStream 监听器。您可以在屏幕的 initState() 上添加它
    AwesomeNotifications().actionStream.listen((receivedNotification) {
    // prints the key of the NotificationActionButton pressed
    debugPrint('Notification key pressed: ${receivedNotification.buttonKeyPressed}');
    });

    关于android - 带有操作按钮和图像的 Flutter 本地通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67791021/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com