refactor: update iOS badge on every notification
This commit is contained in:
parent
0c233c2d57
commit
1775552cd4
4 changed files with 14 additions and 24 deletions
|
|
@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
|
|||
|
||||
import 'package:desktop_lifecycle/desktop_lifecycle.dart';
|
||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||
import 'package:flutter_app_badger/flutter_app_badger.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -31,6 +32,19 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
return;
|
||||
}
|
||||
if (room.notificationCount == 0) return;
|
||||
|
||||
// Workaround for app icon badge not updating
|
||||
if (Platform.isIOS) {
|
||||
final unreadCount =
|
||||
client.rooms.where((room) => room.isUnreadOrInvited).length;
|
||||
if (unreadCount == 0) {
|
||||
FlutterAppBadger.removeBadge();
|
||||
} else {
|
||||
FlutterAppBadger.updateBadgeCount(unreadCount);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final event = Event.fromJson(eventUpdate.content, room);
|
||||
final title =
|
||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(widget.context)!));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue