improved push notification settings with health indicators and optimized notification dismissal
This commit is contained in:
@@ -179,6 +179,29 @@ class DownloadManager {
|
||||
final taskId = job.taskId;
|
||||
if (taskId == null || !Platform.isAndroid) return;
|
||||
final id = _androidNotificationId(taskId);
|
||||
// background_downloader pushes the completion status to us *before* it posts
|
||||
// the "Fertig" notification, and that post runs through a queue throttled to
|
||||
// one notification per ~300ms. When the file opens immediately (lone
|
||||
// foreground download), our first cancel therefore races ahead of the
|
||||
// notification actually appearing and no-ops — leaving it stuck. Re-cancel
|
||||
// across the throttle window so the notification is caught once it lands.
|
||||
for (final delay in _dismissRetryDelays) {
|
||||
if (delay == Duration.zero) {
|
||||
_cancelNotification(id);
|
||||
} else {
|
||||
Future<void>.delayed(delay, () => _cancelNotification(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const _dismissRetryDelays = [
|
||||
Duration.zero,
|
||||
Duration(milliseconds: 350),
|
||||
Duration(milliseconds: 750),
|
||||
Duration(milliseconds: 1500),
|
||||
];
|
||||
|
||||
void _cancelNotification(int id) {
|
||||
unawaited(
|
||||
NotificationService().flutterLocalNotificationsPlugin
|
||||
.cancel(id: id)
|
||||
|
||||
Reference in New Issue
Block a user