TF-1360 Fix open again email detailed when logout app opened from notification
This commit is contained in:
+7
-6
@@ -371,8 +371,8 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleClickLocalNotificationOnTerminated() async {
|
void _handleClickLocalNotificationOnTerminated() async {
|
||||||
await _notificationManager.getNotificationDetails();
|
_notificationManager.activatedNotificationClickedOnTerminate = true;
|
||||||
final notificationResponse = _notificationManager.currentNotificationResponse;
|
final notificationResponse = await _notificationManager.getCurrentNotificationResponse();
|
||||||
log('MailboxDashBoardController::_handleClickLocalNotificationOnTerminated():payload: ${notificationResponse?.payload}');
|
log('MailboxDashBoardController::_handleClickLocalNotificationOnTerminated():payload: ${notificationResponse?.payload}');
|
||||||
final emailIdFromPayload = notificationResponse?.payload;
|
final emailIdFromPayload = notificationResponse?.payload;
|
||||||
final currentAccountId = accountId.value;
|
final currentAccountId = accountId.value;
|
||||||
@@ -391,9 +391,6 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _getSessionCurrent() {
|
void _getSessionCurrent() {
|
||||||
if (BuildUtils.isWeb) {
|
|
||||||
dispatchRoute(DashboardRoutes.thread);
|
|
||||||
}
|
|
||||||
final arguments = Get.arguments;
|
final arguments = Get.arguments;
|
||||||
log('MailboxDashBoardController::_getSessionCurrent(): arguments = $arguments');
|
log('MailboxDashBoardController::_getSessionCurrent(): arguments = $arguments');
|
||||||
if (arguments is Session) {
|
if (arguments is Session) {
|
||||||
@@ -406,10 +403,13 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
injectFCMBindings(sessionCurrent, accountId.value);
|
injectFCMBindings(sessionCurrent, accountId.value);
|
||||||
_getVacationResponse();
|
_getVacationResponse();
|
||||||
|
|
||||||
if (!BuildUtils.isWeb) {
|
if (!BuildUtils.isWeb && !_notificationManager.isNotificationClickedOnTerminate) {
|
||||||
_handleClickLocalNotificationOnTerminated();
|
_handleClickLocalNotificationOnTerminated();
|
||||||
|
} else {
|
||||||
|
dispatchRoute(DashboardRoutes.thread);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
dispatchRoute(DashboardRoutes.thread);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1383,6 +1383,7 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleClickLocalNotificationOnForeground(NotificationResponse? response) {
|
void _handleClickLocalNotificationOnForeground(NotificationResponse? response) {
|
||||||
|
_notificationManager.activatedNotificationClickedOnTerminate = true;
|
||||||
log('MailboxDashBoardController::_handleClickLocalNotificationOnForeground():payload: ${response?.payload}');
|
log('MailboxDashBoardController::_handleClickLocalNotificationOnForeground():payload: ${response?.payload}');
|
||||||
final emailIdFromPayload = response?.payload;
|
final emailIdFromPayload = response?.payload;
|
||||||
final currentAccountId = accountId.value;
|
final currentAccountId = accountId.value;
|
||||||
|
|||||||
+13
-8
@@ -18,7 +18,9 @@ class LocalNotificationManager {
|
|||||||
static LocalNotificationManager get instance => _instance;
|
static LocalNotificationManager get instance => _instance;
|
||||||
|
|
||||||
final _localNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
final _localNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||||
bool notificationsEnabled = false;
|
|
||||||
|
bool _notificationsEnabled = false;
|
||||||
|
bool _isNotificationClickedOnTerminate = false;
|
||||||
|
|
||||||
final StreamController<NotificationResponse> localNotificationsController = StreamController<NotificationResponse>.broadcast();
|
final StreamController<NotificationResponse> localNotificationsController = StreamController<NotificationResponse>.broadcast();
|
||||||
|
|
||||||
@@ -40,16 +42,19 @@ class LocalNotificationManager {
|
|||||||
return Future.value();
|
return Future.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getNotificationDetails() async {
|
Future<NotificationResponse?> getCurrentNotificationResponse() async {
|
||||||
try {
|
try {
|
||||||
_notificationAppLaunchDetails = await _localNotificationsPlugin.getNotificationAppLaunchDetails();
|
_notificationAppLaunchDetails = await _localNotificationsPlugin.getNotificationAppLaunchDetails();
|
||||||
|
return _notificationAppLaunchDetails?.notificationResponse;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError('LocalNotificationManager::getNotificationDetails(): ERROR: ${e.toString()}');
|
logError('LocalNotificationManager::getCurrentNotificationResponse(): ERROR: ${e.toString()}');
|
||||||
}
|
}
|
||||||
return Future.value();
|
return Future.value(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationResponse? get currentNotificationResponse => _notificationAppLaunchDetails?.notificationResponse;
|
set activatedNotificationClickedOnTerminate(bool clicked) => _isNotificationClickedOnTerminate = clicked;
|
||||||
|
|
||||||
|
bool get isNotificationClickedOnTerminate => _isNotificationClickedOnTerminate;
|
||||||
|
|
||||||
Future<bool?> _initLocalNotification() async {
|
Future<bool?> _initLocalNotification() async {
|
||||||
return await _localNotificationsPlugin.initialize(
|
return await _localNotificationsPlugin.initialize(
|
||||||
@@ -69,17 +74,17 @@ class LocalNotificationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _checkLocalNotificationPermission() async {
|
void _checkLocalNotificationPermission() async {
|
||||||
if (notificationsEnabled) {
|
if (_notificationsEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
final granted = await _isAndroidPermissionGranted();
|
final granted = await _isAndroidPermissionGranted();
|
||||||
if (!granted) {
|
if (!granted) {
|
||||||
notificationsEnabled = await _requestPermissions();
|
_notificationsEnabled = await _requestPermissions();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notificationsEnabled = await _requestPermissions();
|
_notificationsEnabled = await _requestPermissions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user