如何在Flutter应用程序中过期/处置通知

发布于 2025-01-25 00:56:13 字数 55 浏览 1 评论 0原文

我在应用程序中启用了通知及其工作正常,但是如果新通知在一定持续时间后到达或到期,我该如何到期呢?

I enabled notifications in my app and its working fine but how can I expire an old notification if a new one arrives or expire it after a certain duration?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不吻晚风 2025-02-01 00:56:13

“ Flutter_local_notifications”插件具有解散通知的方法。但是,目前尚无方法可以获取当前通知的列表。您需要自行跟踪它们(例如,像共享流程这样的持久存储)。

The "flutter_local_notifications" plugin has a method to dismiss notifications. However, there is currently no method to get a list of the present notifications. You need to track them on your own (e.g. some persistent storage like SharedPreferences).

小瓶盖 2025-02-01 00:56:13

检索未决通知请求:

final List<PendingNotificationRequest> pendingNotificationRequests =
    await flutterLocalNotificationsPlugin.pendingNotificationRequests();

的ID值的通知
await flutterLocalNotificationsPlugin.cancel(0);
取消具有零取消/删除所有通知
await flutterLocalNotificationsPlugin.cancelAll();


,您可以通过 flutter_local_notifications

Retrieving pending notification requests :

final List<PendingNotificationRequest> pendingNotificationRequests =
    await flutterLocalNotificationsPlugin.pendingNotificationRequests();

cancel the notification with id value of zero
await flutterLocalNotificationsPlugin.cancel(0);
Cancelling/deleting all notifications
await flutterLocalNotificationsPlugin.cancelAll();


you can achieve this with the flutter_local_notifications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文