2022-01-24 15:35:59 +01:00
|
|
|
import 'package:flutter_app_badger/flutter_app_badger.dart';
|
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
|
|
|
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
|
2023-03-02 10:57:52 +01:00
|
|
|
if (!rooms.any(
|
|
|
|
(r) => r.membership == Membership.invite || (r.notificationCount > 0),
|
|
|
|
)) {
|
2022-01-24 15:35:59 +01:00
|
|
|
// ignore: unawaited_futures
|
|
|
|
FlutterLocalNotificationsPlugin().cancelAll();
|
|
|
|
FlutterAppBadger.removeBadge();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|