TF-1599 Handle remove notification when email mask as read or delete permanent

(cherry picked from commit 1abcc61474728cadca024d21eba43aaf4f09a078)
This commit is contained in:
dab246
2023-04-07 16:02:54 +07:00
committed by Dat Vu
parent fbaea1a951
commit 9dac861baa
10 changed files with 159 additions and 24 deletions
@@ -9,6 +9,7 @@ class LocalNotificationConfig {
static const _channelDescription = 'Team Mail notifications';
static const notificationTitle = 'Team Mail';
static const notificationMessage = 'You have new messages';
static const int groupNotificationId = 1995;
static const iosInitializationSettings = DarwinInitializationSettings();
@@ -151,6 +151,10 @@ class LocalNotificationManager {
);
}
Future<void> removeNotification(String id) {
return _localNotificationsPlugin.cancel(id.hashCode);
}
void groupPushNotification() async {
if (Platform.isIOS) {
return;
@@ -170,7 +174,7 @@ class LocalNotificationManager {
);
await _localNotificationsPlugin.show(
1995,
LocalNotificationConfig.groupNotificationId,
null,
null,
LocalNotificationConfig.instance.generateNotificationDetails(
@@ -181,6 +185,17 @@ class LocalNotificationManager {
}
}
void removeGroupPushNotification() async {
final activeNotifications = await _localNotificationsPlugin
.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
?.getActiveNotifications();
log('LocalNotificationManager::removeGroupPushNotification():activeNotifications: ${activeNotifications?.length}');
if (activeNotifications == null || activeNotifications.length <= 1) {
log('LocalNotificationManager::groupPushNotification():canceled');
await _localNotificationsPlugin.cancel(LocalNotificationConfig.groupNotificationId);
}
}
Future<void> recreateStreamController() {
if (localNotificationsController.isClosed) {
localNotificationsController = StreamController<NotificationResponse>.broadcast();