flutter_local_notification_plus
Enhanced local notifications with rich media, actions, and scheduling for Flutter.
Version 0.0.2 - Now with WASM compatibility and Swift Package Manager support! 🚀
✨ New in 0.0.2
- 🌐 WASM Compatible - Works in web browsers and WebAssembly environments
- 📱 Swift Package Manager - Native iOS and macOS development support
- 🌍 Web Platform - Full web notification implementation
- 🚀 Custom Implementation - No external dependencies, better performance
- 🔮 Future-Proof - Ready for upcoming scoring requirements
Features
- 🎯 Rich Media Support: Display images, videos, and audio in notifications
- ⚡ Advanced Actions: Custom notification actions and responses
- 📅 Flexible Scheduling: Schedule notifications with precise timing
- 🔔 Cross-Platform: Works on iOS, Android, macOS, Windows, Linux, and Web
- 🎨 Customizable: Extensive styling and appearance options
- 🛡️ Permission Handling: Built-in permission management
- 📱 Badge Management: App badge support and management
- 🌐 WASM Ready: WebAssembly compatibility for modern web apps
Getting Started
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
flutter_local_notification_plus: ^0.0.2
Basic Usage
import 'package:flutter_local_notification_plus/flutter_local_notification_plus.dart';
// Initialize the plugin
await FlutterLocalNotificationPlus.initialize();
// Show a simple notification
await FlutterLocalNotificationPlus.showNotification(
id: 1,
title: 'Hello!',
body: 'This is a notification',
);
// Schedule a notification
await FlutterLocalNotificationPlus.scheduleNotification(
id: 2,
title: 'Scheduled',
body: 'This notification was scheduled',
scheduledDate: DateTime.now().add(Duration(minutes: 5)),
);
Advanced Features
Rich Media Notifications
final options = {
'icon': '/path/to/image.png',
'badge': '1',
'tag': 'media_notification',
};
await FlutterLocalNotificationPlus.showNotification(
id: 3,
title: 'Rich Media',
body: 'Check out this image!',
options: options,
);
Custom Actions
final options = {
'actions': ['accept', 'decline'],
'sound': 'custom_sound.mp3',
'vibration': true,
};
await FlutterLocalNotificationPlus.showNotification(
id: 4,
title: 'Action Required',
body: 'Please respond to this notification',
options: options,
);
Scheduling Options
// Schedule for specific time
await FlutterLocalNotificationPlus.scheduleNotification(
id: 5,
title: 'Meeting Reminder',
body: 'Team meeting in 30 minutes',
scheduledDate: DateTime.now().add(Duration(minutes: 30)),
);
// Schedule for specific date and time
final scheduledDate = DateTime(2024, 12, 25, 9, 0); // Christmas morning
await FlutterLocalNotificationPlus.scheduleNotification(
id: 6,
title: 'Christmas!',
body: 'Merry Christmas!',
scheduledDate: scheduledDate,
);
Platform Support
Platform | Status | Features |
---|---|---|
Android | ✅ Full Support | All features available |
iOS | ✅ Full Support | All features + SPM support |
macOS | ✅ Full Support | All features + SPM support |
Windows | ✅ Full Support | All features available |
Linux | ✅ Full Support | All features available |
Web | ✅ Full Support | WASM compatible + browser APIs |
Configuration
Android
Add the following permissions to your android/app/src/main/AndroidManifest.xml
:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
iOS
Add the following to your ios/Runner/Info.plist
:
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
Web
For web applications, the plugin automatically handles browser notification permissions and APIs. No additional configuration is required.
API Reference
Core Methods
initialize()
- Initialize the notification pluginshowNotification()
- Display a notification immediatelyscheduleNotification()
- Schedule a notification for latercancelNotification()
- Cancel a specific notificationcancelAllNotifications()
- Cancel all notificationsgetPendingNotifications()
- Get list of pending notificationsareNotificationsEnabled()
- Check if notifications are enabledrequestPermissions()
- Request notification permissions
Options
icon
- Custom notification iconbadge
- Badge number to displaytag
- Unique identifier for the notificationsound
- Custom sound filevibration
- Enable/disable vibrationactions
- Array of action buttons
Technical Architecture
Native Platforms
- Custom method channel implementation
- Platform-specific notification APIs
- Optimized performance with native code
Web Platform
- Browser notification APIs
- WASM-compatible implementation
- No
dart:io
dependencies
Swift Package Manager
- Native iOS and macOS support
- Package.swift configuration
- Full integration with Apple ecosystem
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions, please:
- Check the documentation
- Search existing issues
- Create a new issue with detailed information
Changelog
See CHANGELOG.md for a list of changes and version history.