【发布时间】:2020-06-16 10:55:57
【问题描述】:
我正在使用flutter_local_notifications 库来安排每 1 小时一次的本地通知。它按预期工作,但现在,我需要一种方法来启动/停止通知计划(例如,按下按钮)。
我在文档中找不到有关取消预定通知请求的任何内容。
【问题讨论】:
标签: flutter dart localnotification
我正在使用flutter_local_notifications 库来安排每 1 小时一次的本地通知。它按预期工作,但现在,我需要一种方法来启动/停止通知计划(例如,按下按钮)。
我在文档中找不到有关取消预定通知请求的任何内容。
【问题讨论】:
标签: flutter dart localnotification
取消/删除通知
// cancel the notification with id value of zero
await flutterLocalNotificationsPlugin.cancel(0);
// 0 is your notification id
取消/删除所有通知
await flutterLocalNotificationsPlugin.cancelAll();
是的,这可以取消当前和未来的通知。只需确保正确的通知 ID。
【讨论】:
在docs 中,它在取消/删除通知中给出
await flutterLocalNotificationsPlugin.cancel(0);
【讨论】:
await flutterLocalNotificationsPlugin.cancelAll();后通知是否没有停止?