notification_manager 1.0.1 copy "notification_manager: ^1.0.1" to clipboard
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() with ComprehensiveNotificationManager.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 functionality
  • firebase_messaging: ^15.2.7 - Firebase Cloud Messaging
  • flutter_local_notifications: ^19.3.0 - Local notifications
  • timezone: ^0.10.1 - Timezone handling
  • flutter_shared_utilities: ^1.0.9 - Utility functions
  • async: ^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 #

0
likes
150
points
57
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter notification manager package that provides local and remote notification support.

Repository (GitHub)
View/report issues

Topics

#notification #push-notifications #firebase-messaging #firebase-notification #local-notifications

Documentation

API reference

License

MIT (license)

Dependencies

async, firebase_core, firebase_messaging, flutter, flutter_local_notifications, flutter_shared_utilities, timezone

More

Packages that depend on notification_manager