【问题标题】:Flutter local notification with action buttons带有操作按钮的 Flutter 本地通知
【发布时间】:2020-06-09 06:27:24
【问题描述】:

我在我的flutter项目中尝试了flutter本地通知插件,它在简单通知上工作正常,但我需要带有操作按钮的通知功能,请帮助我或建议我实现这个功能。

【问题讨论】:

    标签: android ios flutter localnotification


    【解决方案1】:

    awesome_notifications 可用于通过操作按钮推送通知。

    Explanation:
    这可以通过自定义接收到的数据(Json)来完成,例如:

    {
        "to" : "[YOUR APP TOKEN]",
        "mutable_content" : true,
        "content_available": true,
        "priority": "high",
        "data" : {
            "content": {
                "id": 100,
                "channelKey": "big_picture",
                "title": "Huston!\nThe eagle has landed!",
                "body": "A small step for a man, but a giant leap to Flutter's community!",
                "notificationLayout": "BigPicture",
                "largeIcon": "https://media.fstatic.com/kdNpUx4VBicwDuRBnhBrNmVsaKU=/full-fit-in/290x478/media/artists/avatar/2013/08/neil-i-armstrong_a39978.jpeg",
                "bigPicture": "https://www.dw.com/image/49519617_303.jpg",
                "showWhen": true,
                "autoCancel": true,
                "privacy": "Private"
            },
            "actionButtons": [
                {
                    "key": "REPLY",
                    "label": "Reply",
                    "autoCancel": true,
                    "buttonType":  "InputField"
                },
                {
                    "key": "ARCHIVE",
                    "label": "Archive",
                    "autoCancel": true
                }
            ],
            "schedule": {
                "timeZone": "America/New_York",
                "hour": "10",
                "minute": "0",
                "second": "0",
                "millisecond": "0",
                "allowWhileIdle": true,
                "repeat": true
            }
        }
    }
    

    并使用该 messageData 推送通知,例如:

    AwesomeNotifications().createNotificationFromJsonData(yourReceivedMapData);
    

    【讨论】:

      【解决方案2】:

      使用 awesome_notifications: ^0.0.6+7 包

      【讨论】:

        【解决方案3】:

        不幸的是,flutter_local_notifications 插件还不支持操作按钮。有一个 feature request 可以添加这个。

        我不知道任何其他支持此功能的插件,所以我认为现在唯一的可能性是创建您自己的自定义插件并使用本机 iOS 代码进行开发。

        【讨论】:

        • 谢谢乔希,我搜索了所有资源,但没有办法做到这一点。于是开始创建自己的插件
        • @ThulasiRaman 你自己写了插件吗?如果有,你会分享吗?
        猜你喜欢
        • 2021-08-19
        • 2017-12-18
        • 2022-10-04
        • 1970-01-01
        • 2022-08-19
        • 1970-01-01
        • 2023-03-18
        • 1970-01-01
        • 2016-08-18
        相关资源
        最近更新 更多