notification_project_flutter 0.0.2
notification_project_flutter: ^0.0.2 copied to clipboard
A Flutter plugin for handling notifications across iOS and Android platforms with enhanced security.
Notification Project Flutter Plugin #
A Flutter plugin that provides a unified interface for handling notifications across iOS and Android platforms. This plugin wraps the native Notification Project SDKs for both platforms.
Features #
- π Cross-platform notification support
- π― Unified API for iOS and Android
- β‘ Action handling for notifications
- π¨ Customizable notification styles
- π Automatic retry mechanism
- π± Device information management
- π Secure token management
- π Analytics and tracking
- π Multi-language support
Requirements #
- Flutter 3.0.0 or higher
- Dart 2.17.0 or higher
- iOS 13.0 or higher
- Android 5.0 (API level 21) or higher
Installation #
Add the plugin to your pubspec.yaml
file:
dependencies:
notification_project_flutter:
git:
url: https://github.com/yourusername/notification-project-flutter.git
ref: main # or specific version tag
Then run:
flutter pub get
Usage #
Initialize the Plugin #
import 'package:notification_project_flutter/notification_project_flutter.dart';
// Initialize the plugin with your API key
await NotificationProjectFlutter.initialize(
apiKey: 'YOUR_API_KEY',
);
// Set up notification listener
NotificationProjectFlutter.setListener(
onNotificationReceived: (notification) {
// Handle received notification
},
onNotificationAction: (actionId, messageId) {
// Handle notification action
},
onNotificationError: (error) {
// Handle errors
},
);
Send a Notification #
final notification = Notification(
id: 'unique_id',
title: 'Notification Title',
body: 'Notification Body',
data: {'key': 'value'},
style: NotificationStyle(
type: 'default',
backgroundColor: '#FFFFFF',
textColor: '#000000',
),
actions: [
NotificationAction(
id: 'action_1',
title: 'Action 1',
),
],
);
await NotificationProjectFlutter.sendNotification(notification);
Handle Notification Actions #
// Actions are automatically handled through the listener
// You can also manually trigger actions:
await NotificationProjectFlutter.onActionReceived(
actionId: 'action_id',
messageId: 'message_id',
);
API Reference #
NotificationProjectFlutter #
Main class for plugin operations.
Methods
initialize(apiKey: String)
: Initialize the pluginsetListener({onNotificationReceived, onNotificationAction, onNotificationError})
: Set notification listenersendNotification(notification: Notification)
: Send a notificationonActionReceived(actionId: String, messageId: String)
: Handle notification actiongetDeviceToken()
: Get the current device tokenupdateUserProperties(Map<String, dynamic> properties)
: Update user properties
Models #
Notification
class Notification {
final String id;
final String title;
final String body;
final Map<String, dynamic> data;
final NotificationStyle style;
final List<NotificationAction> actions;
}
NotificationStyle
class NotificationStyle {
final String type;
final String backgroundColor;
final String textColor;
}
NotificationAction
class NotificationAction {
final String id;
final String title;
}
Platform Setup #
iOS #
Add the following to your ios/Runner/Info.plist
:
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
Android #
Add the following to your android/app/src/main/AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
Contributing #
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License #
This project is licensed under the MIT License - see the LICENSE file for details.