notification_manager 1.0.1
notification_manager: ^1.0.1 copied to clipboard
A comprehensive Flutter notification manager package that provides local and remote notification support.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.1 - 2025-06-27 #
π Major Improvements #
Singleton Pattern Implementation
- BREAKING CHANGE: Replaced
ComprehensiveNotificationManager.create()
withComprehensiveNotificationManager.getInstance()
- Notification Duplication Fix: Implemented singleton pattern to prevent multiple instances from causing duplicate notifications
- Thread-Safe Initialization: Added proper thread-safe initialization with
Completer
to handle concurrent calls - Defensive Programming: Automatic prevention of notification duplication even if developers accidentally try to create multiple instances
Enhanced Architecture
- Memory Optimization: Improved resource management with singleton pattern
- Stream Safety: Enhanced stream controller management with proper disposal
- Instance Lifecycle: Better control over instance creation and disposal
π Bug Fixes #
- Duplicate Notifications: Fixed issue where Firebase foreground messages were being displayed twice when navigating between different screens
- Stream Controller Errors: Resolved "Cannot add new events after calling close" errors in Firebase repository
- Background Message Handling: Improved background message processing to prevent stream duplication
π Performance Improvements #
- Single Instance: Reduced memory footprint by ensuring only one notification manager instance exists
- Efficient Initialization: Optimized initialization process with proper caching
- Resource Management: Better cleanup and resource disposal
π Migration Guide #
Breaking Changes
Old way (deprecated):
final manager = await ComprehensiveNotificationManager.create();
New way:
final manager = await ComprehensiveNotificationManager.getInstance();
Automatic Benefits
- No Code Changes Required: If you pass the manager instance between screens, no changes needed
- Prevents Duplication: Automatically prevents notification duplication issues
- Better Performance: Improved memory usage and initialization speed
π‘οΈ Safety Improvements #
- Error Prevention: Proactive prevention of common developer mistakes
- Logging: Enhanced debug logging for better troubleshooting
- Stability: More reliable notification handling across app lifecycle
1.0.0 - 2025-06-27 #
π Initial Release #
This is the first stable release of the Flutter Notification Manager package, providing comprehensive notification management for Flutter applications across all platforms.
β¨ Features #
Core Functionality
- Unified Interface: Single API for both Firebase Cloud Messaging (FCM) and local notifications
- Cross-Platform Support: Full support for Android, iOS, Web, Windows, macOS, and Linux
- Type Safety: Complete type safety throughout the implementation with proper error handling
- Initialization Management: Robust initialization system with proper resource cleanup
Notification Management
- Local Notifications: Complete local notification support using
flutter_local_notifications
- Firebase Notifications: Full FCM integration with token management and background handling
- Notification Templates: Pre-built templates for common notification types:
- Basic notifications
- Rich media notifications with images
- Interactive notifications with action buttons
- Message-style notifications
- Reminder notifications
- Promotional notifications
- Progress notifications
- Critical alerts
Scheduling & Timing
- Timezone-Aware Scheduling: Advanced scheduling with proper timezone handling
- Recurring Notifications: Support for daily, weekly, monthly recurring patterns
- Quiet Hours: Automatic notification scheduling around user-defined quiet hours
- Background Scheduling: Reliable scheduling even when app is backgrounded
Permission Management
- Comprehensive Permissions: Handle all notification-related permissions
- Platform-Specific Handling:
- Android 13+ POST_NOTIFICATIONS permission
- Android 12+ exact alarm permissions
- iOS provisional authorization
- Critical alerts support
- Permission Debugging: Detailed permission status checking and debugging tools
- Automatic Retries: Configurable permission request retries with user guidance
User Preferences
- Preference Management: Comprehensive user preference system
- Quiet Hours Settings: Configurable quiet hours with weekday-only options
- Sound & Vibration Control: Per-user sound and vibration preferences
- Blocked Senders: Support for blocking specific notification sources
- Category Preferences: Fine-grained control over notification categories
Rich Features
- Rich Media: Support for images, large icons, and custom styling
- Interactive Actions: Notification action buttons with user input support
- Reply Actions: Direct reply functionality for message notifications
- Channel Management: Create and manage notification channels (Android)
- Delivery Tracking: Monitor notification delivery status (Firebase only)
- Background Handling: Proper background notification processing
Error Handling
- Comprehensive Error Types: Specific error types for different failure scenarios:
- Initialization errors
- Permission errors
- Delivery errors
- Scheduling errors
- Platform-specific errors
- Graceful Degradation: Automatic fallback strategies when services fail
- Debug Support: Extensive logging and debugging capabilities
π§ Technical Implementation #
Architecture
- Clean Architecture: Proper separation of concerns with domain, data, and presentation layers
- Repository Pattern: Unified repository interface for different notification sources
- Singleton Pattern: Efficient resource management with singleton instances
- Stream-Based Events: Reactive programming with stream controllers for events
Platform Integration
- Android:
- Notification channels with automatic creation
- Battery optimization handling
- Exact alarm permissions for Android 12+
- Background notification handling
- iOS:
- Provisional authorization support
- Critical alerts capability
- Rich media attachments
- Background refresh integration
- Web:
- Firebase-only notification support
- Service worker integration
- HTTPS requirement handling
- Desktop:
- Native system notification integration
- Focus assist respect
- Cross-platform desktop support
Dependencies
firebase_core: ^3.14.0
- Firebase core functionalityfirebase_messaging: ^15.2.7
- Firebase Cloud Messagingflutter_local_notifications: ^19.3.0
- Local notificationstimezone: ^0.10.1
- Timezone handlingflutter_shared_utilities: ^1.0.9
- Utility functionsasync: ^2.13.0
- Async utilities
π± Platform Support #
Platform | Local Notifications | Firebase Notifications | Scheduling | Rich Media |
---|---|---|---|---|
Android | β | β | β | β |
iOS | β | β | β | β |
Web | β | β | β | β |
Windows | β | β | β | β |
macOS | β | β | β | β |
Linux | β | β | β | β |
π― Example Integration #
// Initialize the notification manager
final notificationManager = await ComprehensiveNotificationManager.create();
// Set up user preferences
final preferences = UserPreferencesModel(
quietHours: QuietHoursSettings(
enabled: true,
startTime: '22:00',
endTime: '08:00',
),
);
// Initialize with preferences
await notificationManager.initialize(userPreferences: preferences);
// Show a notification
final payload = notificationManager.templates.createBasicNotification(
id: 'welcome',
title: 'Welcome!',
body: 'Your notification system is ready.',
);
await notificationManager.showNotification(payload);
π§ͺ Testing Support #
- Unit Tests: Comprehensive test coverage for core functionality
- Widget Tests: Testing utilities for Flutter widget integration
- Integration Tests: Full end-to-end testing support
- Mock Support: Proper mocking capabilities for testing environments
π Documentation #
- Comprehensive README: Detailed setup and usage instructions
- API Documentation: Complete API reference with examples
- Platform Guides: Platform-specific setup and configuration guides
- Troubleshooting: Common issues and solutions
- Migration Guide: For users coming from other notification packages
π Performance #
- Lazy Loading: Efficient resource loading with lazy initialization
- Memory Management: Proper cleanup and resource disposal
- Background Efficiency: Optimized background processing
- Stream Management: Efficient stream controller management
π Security #
- Permission Validation: Proper permission checking and validation
- Data Sanitization: Safe handling of notification payloads
- Background Security: Secure background notification processing
- Token Management: Secure Firebase token handling
π Quality Assurance #
- Lint Rules: Comprehensive linting with custom Flutter lint rules
- Code Coverage: High test coverage across all modules
- Static Analysis: Advanced static code analysis
- Documentation Coverage: Complete documentation for all public APIs
This initial release provides a solid foundation for notification management in Flutter applications. The package is designed to be production-ready with comprehensive error handling, extensive platform support, and flexible configuration options.
For detailed usage instructions, please refer to the README.md file and the API documentation.
Support & Contributing #
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Contributing: See Contributing Guidelines