From 1d9cdadefb13055b173c4e700810b656de39cc6f Mon Sep 17 00:00:00 2001 From: dab246 Date: Thu, 18 Jan 2024 14:31:09 +0700 Subject: [PATCH] TF-2464 Cannot request notification permission when reload app (cherry picked from commit a98cff8871065c3354c4daaa31e0c29b64f93d65) --- .../notification/local_notification_manager.dart | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/features/push_notification/presentation/notification/local_notification_manager.dart b/lib/features/push_notification/presentation/notification/local_notification_manager.dart index 7d0c6bf56..8b9b42ab1 100644 --- a/lib/features/push_notification/presentation/notification/local_notification_manager.dart +++ b/lib/features/push_notification/presentation/notification/local_notification_manager.dart @@ -25,7 +25,6 @@ class LocalNotificationManager { final _localNotificationsPlugin = FlutterLocalNotificationsPlugin(); - bool _notificationsEnabled = false; bool _isNotificationClickedOnTerminate = false; Stream get localNotificationStream => localNotificationsController.stream; @@ -34,7 +33,8 @@ class LocalNotificationManager { Future setUp() async { try { - await _initLocalNotification(); + final isInitialNotification = await _initLocalNotification(); + log('LocalNotificationManager::setUp:isInitialNotification: $isInitialNotification'); await _checkLocalNotificationPermission(); if (PlatformInfo.isAndroid) { await _createAndroidNotificationChannelGroup(); @@ -79,19 +79,13 @@ class LocalNotificationManager { } Future _checkLocalNotificationPermission() async { - if (_notificationsEnabled) { - return Future.value(null); - } - if (PlatformInfo.isAndroid) { final granted = await _isAndroidPermissionGranted(); if (!granted) { - _notificationsEnabled = await _requestPermissions(); - } else { - _notificationsEnabled = granted; + await _requestPermissions(); } } else if (PlatformInfo.isIOS) { - _notificationsEnabled = await _requestPermissions(); + await _requestPermissions(); } }