fix: Set iOS badge

pull/490/head
Krille 2 years ago
parent eba3eeee25
commit 374d23e79a
No known key found for this signature in database

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

Loading…
Cancel
Save