mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
fix: Set iOS badge
This commit is contained in:
parent
eba3eeee25
commit
374d23e79a
1 changed files with 8 additions and 9 deletions
|
@ -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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue