Athena — roomy-mobile/archive/changes/2026-01-05-fix-notification-permissions/tasks/001-add-permission-handler.md


skill-level: medior status: done

Task: Add permission_handler Package and Permission Service

End Goal

A NotificationPermissionService that wraps permission_handler to check, request, and open settings for notification permissions.

Currently

  • PushNotificationHandler.requestPermission() uses Firebase Messaging's built-in permission request
  • No centralized way to check permission status (granted/denied/undetermined)
  • No ability to open system Settings when permission is denied

Should

  • permission_handler package added to pubspec.yaml
  • iOS and Android platform configurations updated for permission_handler
  • NotificationPermissionService provides:
    • isUndetermined - true when never asked
    • isGranted - true when permission granted
    • isDenied - true when permission denied
    • requestPermission() - triggers OS permission dialog
    • openAppSettings() - opens system Settings app

Constraints

  • [ ] Use permission_handler package (not Firebase Messaging permission API)
  • [ ] Service must be a LazySingleton
  • [ ] Must work on both iOS and Android
  • [ ] Must handle "permanently denied" state on Android

Acceptance Criteria

  • [ ] permission_handler added to pubspec.yaml
  • [ ] iOS Info.plist contains required permission usage description
  • [ ] Android manifest contains required permissions
  • [ ] Service provides accurate permission status
  • [ ] requestPermission() triggers native OS dialog
  • [ ] openAppSettings() opens app settings screen

Implementation Checklist

  • [x] 1.1 Add permission_handler: ^11.3.1 to pubspec.yaml
  • [x] 1.2 Run flutter pub get
  • [x] 1.3 Update iOS Info.plist with NSUserNotificationsUsageDescription if not present
  • [x] 1.4 Create NotificationPermissionService in lib/notifications/services/
  • [x] 1.5 Implement checkStatus() returning PermissionStatus
  • [x] 1.6 Implement isUndetermined, isGranted, isDenied getters
  • [x] 1.7 Implement requestPermission() returning bool
  • [x] 1.8 Implement openAppSettings() using openAppSettings()
  • [x] 1.9 Register service in LocatorService as LazySingleton
  • [x] 1.10 Run flutter analyze to verify no issues

Notes

  • The service wraps permission_handler to provide a cleaner API for the app
  • PermissionStatus.permanentlyDenied on Android means user must go to Settings
  • Consider caching permission status with a listener for changes

Reacties

Nog geen reacties