【发布时间】:2020-06-09 06:27:24
【问题描述】:
我在我的flutter项目中尝试了flutter本地通知插件,它在简单通知上工作正常,但我需要带有操作按钮的通知功能,请帮助我或建议我实现这个功能。
【问题讨论】:
标签: android ios flutter localnotification
我在我的flutter项目中尝试了flutter本地通知插件,它在简单通知上工作正常,但我需要带有操作按钮的通知功能,请帮助我或建议我实现这个功能。
【问题讨论】:
标签: android ios flutter localnotification
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);
【讨论】:
使用 awesome_notifications: ^0.0.6+7 包
【讨论】:
不幸的是,flutter_local_notifications 插件还不支持操作按钮。有一个 feature request 可以添加这个。
我不知道任何其他支持此功能的插件,所以我认为现在唯一的可能性是创建您自己的自定义插件并使用本机 iOS 代码进行开发。
【讨论】: