DjangoFlow Local Notification Package
📬 A streamlined and flexible local notification solution for Flutter mobile apps, seamlessly integrated with DjangoFlow framework to enable dynamic notification actions.
✨ Features
- Initialize the local notification plugin with ease using
NotificationInitializer
. - Seamlessly integrated with DjangoFlow framework and
djangoflow_openapi
package. - Define and manage push action categories for interactive notifications.
- Handle notification data payload and actions conveniently.
- Download and attach images to notifications using
ImageDownloader
. - Modular structure for clean and organized code.
🚀 Installation
Add the following dependency to your pubspec.yaml
file:
dependencies:
djangoflow_local_notification: ^latest_version
Note: This package is designed to work exclusively on Android and iOS platforms. It uses flutter_local_notifications under the hood. You can follow their documentation on platform specific setup and troubleshooting.
🔧 Usage
1. Initialize Notifications
import 'package:djangoflow_local_notification/djangoflow_local_notification.dart';
// Initialize notifications
final notificationInitializer = NotificationInitializer();
await notificationInitializer.initialize(
pushActions: pushActionCategories, // List<PushActionCategory>
defaultAndroidNotificationIcon: 'app_icon',
);
2. Load Push Action Categories
import 'package:djangoflow_local_notification/djangoflow_local_notification.dart';
final actionCategoryCubit = ActionCategoryCubit.instance;
// Load push action categories
await actionCategoryCubit.load();
3. Display Local Notifications
import 'package:djangoflow_local_notification/djangoflow_local_notification.dart';
final localNotificationCubit = LocalNotificationCubit.instance;
await localNotificationCubit.displayNotification(
notificationDetailsBuilder: () async {
// Build NotificationDetails here
return NotificationDetails(/*...*/);
},
id: 1,
title: 'Notification Title',
body: 'Notification Body',
payload: 'payload_data',
);
🎨 Customization
- Customize notification appearance using
NotificationDetails
. - Use custom action categories and actions for interactive notifications.
- Attach images to notifications using
ImageDownloader
.
🛠 Troubleshooting
Android - Notification Icon Not Found in Release Mode
If you're facing issues with notification icons not being found in release mode on Android, you can try the following solution:
-
Create a file named
keep.xml
in theapp/src/main/res/raw/
directory of your Android project. -
Add(create the file if does not exist) the following content to the
keep.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@drawable/*,@raw/slow_spring_board" />
🚀 Examples
Check out the example provided in the example
directory for a practical implementation of the package.
Android Notification
iOS Notification
👏 Contributions and Issues
Contributions, bug reports, and feature requests are welcome! Feel free to submit a pull request or open an issue on the GitHub repository.
📄 License
This package is distributed under the MIT License.