fix: Set iOS badge

This commit is contained in:
Krille 2023-07-29 10:21:03 +02:00
parent eba3eeee25
commit 374d23e79a
No known key found for this signature in database

View file

@ -6,15 +6,14 @@ import 'package:fluffychat/utils/platform_infos.dart';
extension IosBadgeClientExtension on Client {
void updateIosBadge() {
if (PlatformInfos.isIOS) {
// Workaround for iOS not clearing notifications with fcm_shared_isolate
if (!rooms.any(
(r) => r.membership == Membership.invite || (r.notificationCount > 0),
)) {
// ignore: unawaited_futures
FlutterLocalNotificationsPlugin().cancelAll();
FlutterAppBadger.removeBadge();
}
if (!PlatformInfos.isIOS) return;
final unreadCount = rooms.where((room) => room.isUnreadOrInvited).length;
if (unreadCount == 0) {
FlutterAppBadger.removeBadge();
FlutterLocalNotificationsPlugin()
.cancelAll(); // Workaround for iOS not clearing notifications with fcm_shared_isolate
} else {
FlutterAppBadger.updateBadgeCount(unreadCount);
}
}
}