Description:
We are using the flutter_local_notifications package to schedule multiple notifications. Among these, some notifications are scheduled as zonedNotification with the ongoing property set to true. However, there is an unexpected behavior occurring: when the time for the notifications arrives, sometimes two notifications remain active simultaneously. This is not the desired outcome.
Ideally, when the user interacts with (taps on) one of these notifications, the issue should resolve itself by closing other active notifications. However, the following problem occurs:
The function:
var activeNotificationList = await flutterLocalNotificationsPlugin.getActiveNotifications();
does not correctly detect a zonedScheduleNotification that becomes active after it is triggered. In fact, it sometimes returns 0, indicating no active notifications even when there are ongoing notifications. This means that the newly active notifications are not properly identified and managed, leading to multiple ongoing notifications being displayed at the same time.
my example code :
var aktifNotificationList =
await flutterLocalNotificationsPlugin.getActiveNotifications();
if (aktifNotificationList.length !=1) {
for (var notification in aktifNotificationList) {
if (notification.id! >= 15000) {
await flutterLocalNotificationsPlugin.cancel(notification.id!);
}
}
}
Handling Multiple Active Zoned Notifications
Description: We are using the flutter_local_notifications package to schedule multiple notifications. Among these, some notifications are scheduled as zonedNotification with the ongoing property set to true. However, there is an unexpected behavior occurring: when the time for the notifications arrives, sometimes two notifications remain active simultaneously. This is not the desired outcome.
Ideally, when the user interacts with (taps on) one of these notifications, the issue should resolve itself by closing other active notifications. However, the following problem occurs:
The function:
var activeNotificationList = await flutterLocalNotificationsPlugin.getActiveNotifications(); does not correctly detect a zonedScheduleNotification that becomes active after it is triggered. In fact, it sometimes returns 0, indicating no active notifications even when there are ongoing notifications. This means that the newly active notifications are not properly identified and managed, leading to multiple ongoing notifications being displayed at the same time.
my example code :
var aktifNotificationList = await flutterLocalNotificationsPlugin.getActiveNotifications(); if (aktifNotificationList.length !=1) { for (var notification in aktifNotificationList) { if (notification.id! >= 15000) { await flutterLocalNotificationsPlugin.cancel(notification.id!); } } }