alertoon_flutter 1.0.0
alertoon_flutter: ^1.0.0 copied to clipboard
A comprehensive Flutter plugin for Alertoon notification services, supporting both Android and iOS platforms with advanced features like push notifications, device management, and user segmentation.
Alertoon Flutter Plugin #
A comprehensive Flutter plugin for Alertoon notification services, supporting both Android and iOS platforms with advanced features like push notifications, device management, and user segmentation.
Features #
- π Cross-platform push notification support
- π― Unified API for iOS and Android
- β‘ Advanced notification management
- π¨ Customizable notification styles
- π± Device information management
- π Secure API key storage
- π₯ User registration and management
- π·οΈ Tag-based user segmentation
- π Notification analytics and tracking
- β° Scheduled notifications
- π¬ Action handling for notifications
Requirements #
- Flutter 3.0.0 or higher
- Dart 3.0.0 or higher
- iOS 12.0 or higher
- Android API level 24 or higher
Installation #
Add the plugin to your pubspec.yaml
file:
dependencies:
alertoon_flutter: ^1.0.0
Then run:
flutter pub get
Usage #
Initialize the Plugin #
import 'package:alertoon_flutter/alertoon_flutter.dart';
// Initialize the plugin with your API key
await NotificationProjectFlutter.initialize(
apiKey: 'YOUR_API_KEY',
channelId: 'default_channel',
channelName: 'Default Channel',
channelDescription: 'Default notification channel',
defaultIcon: 'ic_notification',
);
Register a User #
// Register a new user/consumer
final consumerId = await NotificationProjectFlutter.registerConsumer(
externalUserId: 'user_123',
deviceToken: 'device_token_here',
deviceInfo: {
'platform': 'android',
'osVersion': '13',
'appVersion': '1.0.0',
},
);
Send Notifications #
// Send a notification to specific users
await NotificationProjectFlutter.sendNotification(
applicationId: 'your_app_id',
tokens: ['device_token_1', 'device_token_2'],
title: 'Hello World',
body: 'This is a test notification',
image: 'https://example.com/image.jpg',
data: {'key': 'value'},
android: {
'priority': 'high',
'notification': {
'icon': 'ic_notification',
'color': '#FF0000',
},
},
);
Create and Send Notification #
// Create a notification and send it immediately
final notificationId = await NotificationProjectFlutter.createAndSendNotification(
title: 'Scheduled Notification',
message: 'This notification was scheduled',
consumerIds: ['consumer_1', 'consumer_2'],
scheduledTime: DateTime.now().add(Duration(hours: 1)),
timezone: 'UTC',
);
Tag Management #
// Assign a tag to a user
await NotificationProjectFlutter.assignTag(
consumerId: 'consumer_123',
tagName: 'premium_users',
);
// List all tags for a user
final tags = await NotificationProjectFlutter.listTags(
consumerId: 'consumer_123',
);
// Remove a tag from a user
await NotificationProjectFlutter.removeTag(
consumerId: 'consumer_123',
tagName: 'premium_users',
);
// Create a new tag
await NotificationProjectFlutter.createTag(
tagName: 'beta_testers',
externalUserIds: ['user_1', 'user_2'],
);
Device Information #
// Get device information
final deviceInfo = await NotificationProjectFlutter.getDeviceInfo();
print('Device ID: ${deviceInfo.deviceId}');
print('Platform: ${deviceInfo.platform}');
print('OS Version: ${deviceInfo.osVersion}');
// Update device information
await NotificationProjectFlutter.updateDeviceInfo({
'platform': 'android',
'osVersion': '13',
'appVersion': '1.0.0',
'deviceModel': 'Pixel 7',
});
Notification Management #
// Get a specific notification
final notification = await NotificationProjectFlutter.getNotification(
notificationId: 'notification_123',
);
// Update a notification
await NotificationProjectFlutter.updateNotification(
notificationId: 'notification_123',
title: 'Updated Title',
message: 'Updated message',
);
// Delete a notification
await NotificationProjectFlutter.deleteNotification(
notificationId: 'notification_123',
);
// Get all notifications for an application
final notifications = await NotificationProjectFlutter.getNotificationsByApplication(
page: 1,
limit: 10,
search: 'test',
sortBy: 'createdAt',
sortOrder: 'desc',
);
API Reference #
NotificationProjectFlutter #
Main class for plugin operations.
Methods
initialize({required String apiKey, String? channelId, String? channelName, String? channelDescription, String? defaultIcon})
: Initialize the pluginregisterConsumer({required String externalUserId, String? deviceToken, Map<String, dynamic>? deviceInfo})
: Register a new usergetDeviceInfo()
: Get current device informationupdateDeviceInfo(Map<String, dynamic> deviceInfo)
: Update device informationgetToken()
: Get the current device tokensendNotification({required String applicationId, required List<String> tokens, required String title, required String body, String? image, Map<String, dynamic>? data, Map<String, dynamic>? android})
: Send a notificationcreateNotification({required String title, required String message, ...})
: Create a notificationcreateAndSendNotification({required String title, required String message, ...})
: Create and send a notificationassignTag({required String consumerId, required String tagName})
: Assign a tag to a userlistTags({required String consumerId})
: List all tags for a userremoveTag({required String consumerId, required String tagName})
: Remove a tag from a usercreateTag({required String tagName, List<String>? externalUserIds, List<String>? consumerIds})
: Create a new taggetNotification({required String notificationId})
: Get a specific notificationupdateNotification({required String notificationId, ...})
: Update a notificationdeleteNotification({required String notificationId})
: Delete a notificationgetNotificationsByApplication({int? page, int? limit, String? search, String? sortBy, String? sortOrder})
: Get all notifications for an application
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"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
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.