TF-1317 Show push notification on background or terminated app

This commit is contained in:
dab246
2023-01-09 17:01:34 +07:00
committed by Dat H. Pham
parent 97583820fa
commit 7367d7e1d2
12 changed files with 292 additions and 96 deletions
@@ -7,6 +7,8 @@ class LocalNotificationConfig {
static const _channelId = 'team_mail_notification_channel_id';
static const _channelName = 'Team Mail notifications';
static const _channelDescription = 'Team Mail notifications';
static const notificationTitle = 'Team Mail';
static const notificationMessage = 'You have new messages';
static const iosInitializationSettings = DarwinInitializationSettings();
@@ -53,6 +55,7 @@ class LocalNotificationConfig {
presentSound: true,
presentAlert: true,
presentBadge: true,
threadIdentifier: _channelId
),
);
}
@@ -8,6 +8,8 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
import 'package:model/extensions/email_address_extension.dart';
import 'package:tmail_ui_user/features/push_notification/presentation/notification/local_notification_config.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
class LocalNotificationManager {
@@ -159,7 +161,9 @@ class LocalNotificationManager {
if (activeNotifications != null && activeNotifications.isNotEmpty) {
final inboxStyleInformation = InboxStyleInformation(
[''],
summaryText: '${activeNotifications.length - 1} new emails'.addBlockTag('b'),
summaryText: currentContext != null
? AppLocalizations.of(currentContext!).totalNewMessagePushNotification(activeNotifications.length - 1).addBlockTag('b')
: '${activeNotifications.length - 1} new emails'.addBlockTag('b'),
htmlFormatSummaryText: true,
);