ComprehensiveNotificationManager class

Comprehensive notification manager that provides a unified interface for all notification operations across Firebase and local notifications.

This class uses a singleton pattern to prevent multiple instances from causing duplicate notifications.

Properties

fcmToken → String?
Gets the current Firebase FCM token. Returns null if Firebase is not available or token is not ready.
no setter
foregroundManager → ForegroundNotificationManager?
Foreground notification manager for in-app dialogs.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isInitialized → bool
Whether the manager has been initialized.
no setter
onNotificationAction → Stream<Map<String, String?>>
Stream of notification action events from both Firebase and Local sources.
no setter
onNotificationDismissed → Stream<String>
Stream of dismissed notification IDs from both Firebase and Local sources.
no setter
onNotificationOpened → Stream<NotificationPayload>
Stream of opened notifications from both Firebase and Local sources.
no setter
onNotificationReceived → Stream<NotificationPayload>
Stream of received notifications from both Firebase and Local sources. Automatically deduplicates notifications based on ID and timestamp.
no setter
permissionManager → NotificationPermissionManager
Permission manager for handling notification permissions.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
templates → NotificationTemplateBuilder
Template builder for creating pre-defined notification templates.
no setter

Methods

areNotificationsEnabled() → Future<(NotificationFailure?, bool?)>
Checks if notifications are currently enabled. Uses local repository for permission checking.
cancelAllNotifications() → Future<NotificationFailure?>
Cancels all pending notifications. Cancels from both repositories.
cancelNotification(String id) → Future<NotificationFailure?>
Cancels a specific notification by ID. Tries both repositories to ensure cancellation.
checkPermissionStatus() → Future<(NotificationFailure?, PermissionStatus)>
Checks the comprehensive permission status.
createNotificationChannel({required String channelId, required String channelName, String? channelDescription, NotificationImportance? importance, bool? enableVibration, bool? enableLights, String? sound}) → Future<NotificationFailure?>
Creates a notification channel. Uses local repository for channel creation.
deleteFirebaseToken() → Future<NotificationFailure?>
Deletes the Firebase FCM token. This is primarily useful for testing and debugging scenarios. After deletion, a new token will be generated on the next app launch.
dispose() → Future<NotificationFailure?>
Disposes the notification manager and cleans up resources.
getDeliveredNotifications() → Future<(NotificationFailure?, List<NotificationEntity>?)>
Gets all delivered notifications from both repositories.
getPendingNotifications() → Future<(NotificationFailure?, List<NotificationEntity>?)>
Gets all pending notifications from both repositories.
getUserPreferences() → UserPreferencesModel?
Gets the current user preferences.
initialize({bool autoRequestPermissions = true, UserPreferencesModel? userPreferences}) → Future<NotificationFailure?>
Initializes the notification manager and sets up all repositories.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openNotificationSettings() → Future<NotificationFailure?>
Opens the system notification settings. Uses local repository for settings navigation.
refreshFirebaseToken() → Future<String?>
Refreshes the Firebase FCM token. Returns the new token or null if refresh failed.
requestAllPermissions([PermissionRequestConfig config = const PermissionRequestConfig()]) → Future<(NotificationFailure?, PermissionStatus)>
Requests all notification permissions with comprehensive handling.
requestPermissions() → Future<(NotificationFailure?, bool?)>
Requests notification permissions from the user. This is the legacy method that returns a simple boolean. For more detailed permission handling, use requestAllPermissions.
runSchedulingDiagnostics() → Future<Map<String, dynamic>>
Runs comprehensive diagnostics for scheduled notifications debugging.
scheduleNotification(NotificationPayload payload, DateTime scheduledTime, {bool respectUserPreferences = true, bool respectQuietHours = false}) → Future<NotificationFailure?>
Schedules a notification for future delivery. Uses local repository for scheduling.
scheduleRecurringNotification(NotificationPayload payload, DateTime firstScheduledTime, RepeatInterval repeatInterval, {DateTime? endDate, bool respectUserPreferences = true, bool respectQuietHours = true}) → Future<NotificationFailure?>
Schedules a recurring notification. Uses local repository for recurring scheduling.
showForegroundDialog(NotificationPayload payload, BuildContext? context) → Future<NotificationFailure?>
Shows a foreground notification dialog if the app is in foreground.
showNotification(NotificationPayload payload, {bool respectUserPreferences = true}) → Future<NotificationFailure?>
Shows a notification immediately with user preferences applied. Uses local repository for immediate display.
subscribeToFirebaseTopic(String topic) → Future<NotificationFailure?>
Subscribes to a Firebase topic.
toString() → String
A string representation of this object.
inherited
unsubscribeFromFirebaseTopic(String topic) → Future<NotificationFailure?>
Unsubscribes from a Firebase topic.
updateUserPreferences(UserPreferencesModel preferences) → Future<NotificationFailure?>
Updates user preferences for notifications.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

getInstance({FirebaseNotificationRepository? firebaseRepository, LocalNotificationRepository? localRepository, NotificationTemplateBuilder? templateBuilder, NotificationScheduler? scheduler, NotificationPermissionManager? permissionManager, ForegroundNotificationConfig? foregroundConfig}) → Future<ComprehensiveNotificationManager>
Gets the singleton instance with proper initialization.