alertoon_flutter 1.0.0 copy "alertoon_flutter: ^1.0.0" to clipboard
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 plugin
  • registerConsumer({required String externalUserId, String? deviceToken, Map<String, dynamic>? deviceInfo}): Register a new user
  • getDeviceInfo(): Get current device information
  • updateDeviceInfo(Map<String, dynamic> deviceInfo): Update device information
  • getToken(): Get the current device token
  • sendNotification({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 notification
  • createNotification({required String title, required String message, ...}): Create a notification
  • createAndSendNotification({required String title, required String message, ...}): Create and send a notification
  • assignTag({required String consumerId, required String tagName}): Assign a tag to a user
  • listTags({required String consumerId}): List all tags for a user
  • removeTag({required String consumerId, required String tagName}): Remove a tag from a user
  • createTag({required String tagName, List<String>? externalUserIds, List<String>? consumerIds}): Create a new tag
  • getNotification({required String notificationId}): Get a specific notification
  • updateNotification({required String notificationId, ...}): Update a notification
  • deleteNotification({required String notificationId}): Delete a notification
  • getNotificationsByApplication({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 #

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License #

This project is licensed under the MIT License - see the LICENSE file for details.

1
likes
130
points
110
downloads

Publisher

unverified uploader

Weekly Downloads

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.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

unknown (license)

Dependencies

crypto, flutter, flutter_secure_storage, http, local_auth, plugin_platform_interface

More

Packages that depend on alertoon_flutter

Packages that implement alertoon_flutter