Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix notification permission denial flow

ashilkn2c5bc705dd10
diff --git a/mobile/apps/photos/lib/services/notification_service.dart b/mobile/apps/photos/lib/services/notification_service.dart
index 3effb92a6e..b1afe44ba0 100644
--- a/mobile/apps/photos/lib/services/notification_service.dart
+++ b/mobile/apps/photos/lib/services/notification_service.dart
@@ -20,6 +20,8 @@ class NotificationService {
"notifications_enabled_shared_photos";
static const String keyShouldShowSocialNotifications =
"notifications_enabled_social";
+ static const String _keyHasAttemptedNotificationPermission =
+ "has_attempted_notification_permission";
NotificationService._privateConstructor();
@@ -165,7 +167,15 @@ class NotificationService {
Future<bool> requestPermissions(BuildContext context) async {
if (await hasGrantedPermissions()) return true;
if (!context.mounted) return false;
- if (await _askPermissions()) return true;
+
+ final hasAttemptedPermission =
+ _preferences.getBool(_keyHasAttemptedNotificationPermission) ?? false;
+ if (!hasAttemptedPermission) {
+ await _preferences.setBool(_keyHasAttemptedNotificationPermission, true);
+ if (!context.mounted) return false;
+ return _askPermissions();
+ }
+
if (!context.mounted) return false;
await _openNotificationSettings();
const interval = Duration(milliseconds: 500);