TF-2464 Cannot request notification permission when reload app
(cherry picked from commit a98cff8871065c3354c4daaa31e0c29b64f93d65)
This commit is contained in:
+4
-10
@@ -25,7 +25,6 @@ class LocalNotificationManager {
|
||||
|
||||
final _localNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||
|
||||
bool _notificationsEnabled = false;
|
||||
bool _isNotificationClickedOnTerminate = false;
|
||||
|
||||
Stream<NotificationResponse> get localNotificationStream => localNotificationsController.stream;
|
||||
@@ -34,7 +33,8 @@ class LocalNotificationManager {
|
||||
|
||||
Future<void> 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<void> _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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user