Awesome Notifications for Flutter

Awesome Notifications

Flutter Firebase Discord

Open Source Love pub package Full tests workflow codecov badge

Engage your users with custom local and push notifications on Flutter, on Android, iOS, macOS, Windows, Linux and the Web. Get real-time events and never miss a user interaction with Awesome Notifications.

A big picture notification on the iOS lock screen, in the app and in the Android notification shade

The example app (center), a big picture notification on the iOS lock screen (left) and the same notification, next to one with action buttons, in the Android notification shade (right).



Key Features:



Android notification examples:


iOS notification examples:


Notification Types Available

  • Basic notification
  • Big picture notification
  • Big text notification
  • Inbox notification
  • Notifications with action buttons and typed replies
  • Grouped notifications
  • Progress bar notifications (Android; the Web shows the percentage)
  • Messaging and messaging group notifications (richer with awesome_notifications_chat)
  • Media player notifications (richer with awesome_notifications_media)
  • Call, live activity and foreground service notifications (each in its add-on package)

All notification types can be created locally or received by push, with all the features and customizations available.



๐Ÿ“™ Table of Contents



๐Ÿ”ถ Main Philosophy of Awesome Notifications

We make notifications straightforward and feature-rich, so you focus on what to say, not on what each device can do. Every package of the family follows the same principles:

  • One call, the same effect everywhere. A notification created on one platform looks and behaves the same on every other, as far as the platform allows. Where Android and iOS behave differently, macOS follows iOS, and Windows, Linux and the Web follow Android.
  • A small core, one package per feature. The core shows notifications and reports their events; scheduling, translations, chat, media, calls, live activities, foreground services and push are add-on packages. Your app carries only what it uses.
  • Everything goes through the core. Add-ons and push packages hand their notifications to the core, so channels, permissions, layouts, buttons, images and the four events work the same, whatever created the notification.
  • Never an error for a missing platform. A call that a platform can't do answers "unavailable" (false, an empty list, null) instead of throwing, and a feature a device doesn't have (an LED light, a full screen intent) is simply left out. One code base runs everywhere.
  • Consistent delivery. Every event that happens while your app isn't listening (closed, or before setListeners) is kept and delivered as soon as the app listens again.
  • Idempotent pushes. A push that arrives twice is shown once and reported once (each push package's README explains how).
  • Notification channels everywhere. Android's channels are emulated on every other platform: the same channels, with the same settings, wherever your app runs.
  • App badge everywhere. iOS's app badge counter is emulated on every other platform, with the same methods.


๐Ÿ“ฑ Platform support

Package Push Android iOS macOS Windows Linux Web
awesome_notifications (this core) ๐Ÿ”— โœ… โœ… โœ… ๐Ÿงช ๐Ÿงช ๐Ÿงช
awesome_notifications_schedules ๐Ÿ”— โœ… โœ… โœ… ๐Ÿงช ๐Ÿงช โŒ
awesome_notifications_localizations ๐Ÿ”— โœ… โœ… โœ… ๐Ÿงช ๐Ÿงช ๐Ÿงช
awesome_notifications_fcm โœ… โœ… โœ… โœ… โŒ โŒ ๐Ÿงช
awesome_notifications_wns โœ… โŒ โŒ โŒ ๐Ÿงช โŒ โŒ
awesome_notifications_unifiedpush โœ… ๐Ÿงช โŒ โŒ โŒ ๐Ÿงช โŒ
awesome_notifications_onesignal โœ… ๐Ÿงช ๐Ÿงช โŒ โŒ โŒ โŒ
awesome_notifications_braze โœ… ๐Ÿงช ๐Ÿงช โŒ โŒ โŒ โŒ
awesome_notifications_airship โœ… ๐Ÿงช ๐Ÿงช โŒ โŒ โŒ โŒ
awesome_notifications_chat ๐Ÿ”— โœ… โœ… โœ… ๐Ÿงช ๐Ÿงช ๐Ÿงช
awesome_notifications_media โŒ โœ… โœ… โœ… ๐Ÿงช ๐Ÿงช ๐Ÿงช
awesome_notifications_calls ๐Ÿ”— โœ… โœ… ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
awesome_notifications_live_activities ๐Ÿ”— โœ… โœ… ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
awesome_notifications_foreground_service โŒ โœ… โŒ โŒ โŒ โŒ โŒ

โœ… supported ยท ๐Ÿ”— works with push ยท ๐Ÿงช preview (implemented, still being validated) ยท โณ planned ยท โŒ not available on this platform

Each package's README details its own gaps.

Minimum versions: Flutter 3.44 (Dart 3.12) ยท Android 7.0 (API 24), compiled with API 36 ยท iOS 13 ยท macOS 10.15 ยท Windows 10 ยท Linux with a notification server on D-Bus ยท the Web on a browser with the Notifications API.

Web shows the browser's notifications, compiled to JavaScript or to WebAssembly, through a service worker the plugin registers by itself (nothing to set up). The notifications have their action buttons (the browser shows two on most systems; a button that needs typed text is left out), their clicks reach the app after the page reloads, and a click that brings the app (ActionType.Default) opens it when its tab was closed, as the launch action (getInitialNotificationAction). requestPermissionToSendNotifications opens the browser's prompt, the four events carry the whole content and closing a notification is a dismissal. A page loads https:// and asset:// images (not file:// nor resource://); a big picture without a large icon is also shown as the large icon, so browsers that can't draw the big image (macOS, Firefox, Safari) still show it. The service worker needs a secure page (https:// or localhost); elsewhere the plugin shows page notifications, without buttons, while the page is open. To try it, run the app with flutter run -d web-server and open it in your own browser: the Chrome that flutter run -d chrome opens has notifications disabled.

Current Web gaps:

  • a SilentAction or KeepOnTop button reaches the app only while one of its tabs is open (with no tab, there is no Dart to run it);
  • a dismissal reaches the app only while one of its tabs is open.

Windows shows the system's toast notifications. The plugin registers the app's identity for the current user by itself, so an app that isn't packaged (a plain .exe, flutter run) needs no setup. The badge counter is kept, but the app icon doesn't show it yet, and the settings pages (showNotificationConfigPage, showAlarmPage, showGlobalDndOverridePage) do nothing yet.

Linux uses the Desktop Notifications Specification (org.freedesktop.Notifications over D-Bus), so it works with GNOME, KDE, XFCE, dunst, mako and other notification servers. What a notification shows depends on the server: images, action buttons and typed replies (KDE) appear where the server supports them, and are left out elsewhere. Network images are downloaded with the system's libcurl, loaded at run time, so the build needs no extra packages. Linux has no notification permission an app can read: notifications are allowed whenever a notification server is running. As on Windows, the badge counter is kept but not shown, and the settings pages do nothing yet.

Current Linux gaps, planned for a follow-up (a small helper bundled with the app):

  • the app must be running to receive taps, buttons and dismissals; a notification tapped after the app closed does nothing.

macOS follows iOS: the same permissions, channels emulated by the plugin, and the badge on the Dock icon.



๐Ÿ›‘ Incompatible plugins

  • Other local notification plugins (flutter_local_notifications and the like): they compete with awesome_notifications for the same global notification resources (the notification center delegate on iOS and macOS, the notification events on Android), so the events of one of them get lost. Use only one notification plugin.

Each push package lists, in its README, the plugins it can't be combined with.

If you have any questions, visit our Discord Community.



๐Ÿ›  Getting Started

Installation

Add the core, and only the add-ons you use, to your pubspec.yaml. Every package of the family follows the same version line:

dependencies:
  awesome_notifications: ^1.0.0-dev.10 # the core

  # Add-ons: only the ones you use
  awesome_notifications_schedules: ^1.0.0-dev.10       # scheduled notifications
  awesome_notifications_localizations: ^1.0.0-dev.10   # translated notifications
  awesome_notifications_chat: ^1.0.0-dev.10            # chat / communication notifications
  awesome_notifications_media: ^1.0.0-dev.10           # media player controls
  awesome_notifications_calls: ^1.0.0-dev.10           # calls (CallKit, CallStyle, VoIP pushes)
  awesome_notifications_live_activities: ^1.0.0-dev.10 # iOS Live Activities, Android Live Updates
  awesome_notifications_foreground_service: ^1.0.0-dev.10 # Android foreground services

  # Push: one package per push service
  awesome_notifications_fcm: ^1.0.0-dev.10         # Android, iOS, macOS, Web (Firebase Cloud Messaging)
  awesome_notifications_wns: ^1.0.0-dev.10         # Windows (Windows Push Notification Services)
  awesome_notifications_unifiedpush: ^1.0.0-dev.10 # Android, Linux (UnifiedPush)
  awesome_notifications_onesignal: ^1.0.0-dev.10   # Android, iOS (OneSignal, with onesignal_flutter)
  awesome_notifications_braze: ^1.0.0-dev.10       # Android, iOS (Braze, with braze_plugin)
  awesome_notifications_airship: ^1.0.0-dev.10     # Android, iOS (Airship, with airship_flutter)

Each push package has its own setup (the service's account, files and permissions): see its README.

Then run:

flutter pub get

๐Ÿค– Android

Set the SDK versions in android/app/build.gradle.kts:

android {
    compileSdk = 36

    defaultConfig {
        minSdk = 24
        targetSdk = 36
    }
}

In android/app/src/main/AndroidManifest.xml, every <activity>, <activity-alias>, <service> or <receiver> with an <intent-filter> needs android:exported (Android 12 and later refuse to install the app otherwise):

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application>
        <activity
            android:name=".MainActivity"
            android:exported="true">
            ...
        </activity>
    </application>
</manifest>

The plugin declares the notification permission (POST_NOTIFICATIONS) by itself. The features that need another permission (precise alarms, critical alerts, full screen, waking the screen) list it in their own sections.


๐ŸŽ iOS

With Swift Package Manager (Flutter's default), nothing to set up. With CocoaPods, point the app's ios/Podfile to the engine the plugin ships, inside target 'Runner':

target 'Runner' do
  use_frameworks!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  pod 'IosAwnCore', :path => '.symlinks/plugins/awesome_notifications/ios'
  # ...
end

Critical alerts need an entitlement: see Critical Alerts.


๐Ÿ’ป macOS

macOS 10.15 or later. With Swift Package Manager (Flutter's default), nothing to set up. With CocoaPods, point the app's macos/Podfile to the engine the plugin ships, inside target 'Runner':

target 'Runner' do
  use_frameworks!

  flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
  pod 'IosAwnCore', :path => 'Flutter/ephemeral/.symlinks/plugins/awesome_notifications/ios'
  # ...
end

๐ŸชŸ Windows

Nothing to set up: the plugin registers the app's identity for the notifications by itself.


๐Ÿง Linux

Nothing to set up. The user's desktop needs a notification server (every desktop environment has one).


๐ŸŒ Web

Nothing to set up: the plugin registers its own service worker. Serve the app over https (or localhost) to have action buttons and taps that open a closed tab.



๐Ÿš€ Your First Notification

  1. Import the plugin:
import 'package:awesome_notifications/awesome_notifications.dart';
  1. Initialize it in main(), before runApp, with at least one channel. The icon is an Android drawable resource (null uses the app icon):
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await AwesomeNotifications().initialize(
    // null uses the app icon
    'resource://drawable/res_app_icon',
    [
      NotificationChannel(
        channelGroupKey: 'basic_channel_group',
        channelKey: 'basic_channel',
        channelName: 'Basic notifications',
        channelDescription: 'Notification channel for basic tests',
        defaultColor: const Color(0xFF9D50DD),
        ledColor: Colors.white,
      ),
    ],
    // Channel groups are only visual and are not required
    channelGroups: [
      NotificationChannelGroup(
        channelGroupKey: 'basic_channel_group',
        channelGroupName: 'Basic group',
      ),
    ],
    debug: true,
  );
  runApp(const MyApp());
}
  1. Create static (or top-level) methods to receive the events. Mark each one with @pragma('vm:entry-point'): the native side calls them, even with the app closed.
class NotificationController {
  /// A new notification or schedule was created
  @pragma('vm:entry-point')
  static Future<void> onNotificationCreatedMethod(
      ReceivedNotification receivedNotification) async {}

  /// A notification was displayed
  @pragma('vm:entry-point')
  static Future<void> onNotificationDisplayedMethod(
      ReceivedNotification receivedNotification) async {}

  /// The user dismissed a notification
  @pragma('vm:entry-point')
  static Future<void> onDismissActionReceivedMethod(
      ReceivedAction receivedAction) async {}

  /// The user tapped a notification or one of its buttons
  @pragma('vm:entry-point')
  static Future<void> onActionReceivedMethod(
      ReceivedAction receivedAction) async {
    // Opens the notification page, without stacking it on another one
    MyApp.navigatorKey.currentState?.pushNamedAndRemoveUntil(
      '/notification-page',
      (route) => (route.settings.name != '/notification-page') || route.isFirst,
      arguments: receivedAction,
    );
  }
}
  1. Set the listeners in your app's first initState. The events are delivered only after setListeners; the ones that happened before are kept until then. A global navigator key lets the static methods navigate:
class MyApp extends StatefulWidget {
  const MyApp({super.key});

  static final navigatorKey = GlobalKey<NavigatorState>();

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    AwesomeNotifications().setListeners(
      onActionReceivedMethod: NotificationController.onActionReceivedMethod,
      onNotificationCreatedMethod:
          NotificationController.onNotificationCreatedMethod,
      onNotificationDisplayedMethod:
          NotificationController.onNotificationDisplayedMethod,
      onDismissActionReceivedMethod:
          NotificationController.onDismissActionReceivedMethod,
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: MyApp.navigatorKey,
      initialRoute: '/',
      onGenerateRoute: (settings) => switch (settings.name) {
        '/notification-page' => MaterialPageRoute(
            builder: (context) => NotificationPage(
                receivedAction: settings.arguments as ReceivedAction)),
        _ => MaterialPageRoute(builder: (context) => const HomePage()),
      },
    );
  }
}

Anonymous functions are not valid listeners: they can't be called from a closed app. To reach a BuildContext, use the navigator key, as above.

  1. Ask the user's permission (explain why first, in your own dialog):
final isAllowed = await AwesomeNotifications().isNotificationAllowed();
if (!isAllowed) {
  // Show your own dialog first, explaining why, then:
  await AwesomeNotifications().requestPermissionToSendNotifications();
}
  1. Create a notification, anywhere in your app:
await AwesomeNotifications().createNotification(
  content: NotificationContent(
    id: 10,
    channelKey: 'basic_channel',
    actionType: ActionType.Default,
    title: 'Hello World!',
    body: 'This is my first notification!',
  ),
);

This creates a notification with the id 10, on the basic_channel channel, that brings the app to the foreground when tapped.

๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ THAT'S IT! CONGRATZ MY FRIEND!!! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰


๐Ÿ“ Important notes

  1. Initialize every Awesome Notifications package at each start, even if the app has no permission to show notifications.

  2. To know, before setListeners, whether a notification tap started the app, call getInitialNotificationAction. It answers the action that started the app, or null. It doesn't remove the action from onActionReceivedMethod, unless removeFromActionEvents is true.

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await AwesomeNotifications().initialize(null, [/* your channels */]);
  final receivedAction = await AwesomeNotifications()
      .getInitialNotificationAction(removeFromActionEvents: false);
  runApp(MyApp(
      initialPage: receivedAction?.channelKey == 'call_channel' ? '/call' : '/'));
}
  1. A SilentBackgroundAction runs in a separate Dart isolate, without a BuildContext. To act on the main isolate (navigate, update the UI), send the action through a SendPort:
class NotificationController {
  static ReceivePort? _receivePort;

  /// Call it once, on the main isolate, when the app starts
  static void startListeningOnMainIsolate() {
    _receivePort = ReceivePort('Notification action port in main isolate')
      ..listen((data) => _handleAction(ReceivedAction().fromMap(data)));
    IsolateNameServer.registerPortWithName(
        _receivePort!.sendPort, 'notification_actions');
  }

  @pragma('vm:entry-point')
  static Future<void> onActionReceivedMethod(ReceivedAction received) async {
    if (_receivePort == null) {
      // A background isolate: forward the action to the main one, if it runs
      final sendPort =
          IsolateNameServer.lookupPortByName('notification_actions');
      if (sendPort != null) {
        sendPort.send(received.toMap());
        return;
      }
    }
    await _handleAction(received);
  }

  static Future<void> _handleAction(ReceivedAction received) async {
    // Your code
  }
}
  1. On Android, when the user leaves the app with the back button and reopens it from the recent apps, Android repeats the intent that started it. If a notification started the app, its action is delivered again: handle that case in your app if it matters.


๐Ÿ” Migrating from 0.12.1

1.0.0 splits the plugin into a small core and add-on packages. Your notifications, channels, listeners and permissions keep the same code; what changes is the package of some features:

In 0.12.1 In 1.0.0
createNotification(schedule: NotificationCalendar(...)) add awesome_notifications_schedules and pass the schedule in extensions: [NotificationCalendar(...)]
AwesomeNotifications().listScheduledNotifications(), cancelSchedule, cancelSchedulesByChannelKey, cancelSchedulesByGroupKey, cancelAllSchedules, getNextDate the same methods on AwesomeNotificationsSchedules()
NotificationAndroidCrontab not available yet
createNotification(localizations: {...}) add awesome_notifications_localizations and pass extensions: [NotificationLocalizations({...})]
AwesomeNotifications().setLocalization / getLocalization AwesomeNotificationsLocalizations().setLocalization / getLocalization
import 'package:awesome_notifications/android_foreground_service.dart' add awesome_notifications_foreground_service and import it
The iOS Podfile modifications (AwesomePodFile) remove them. With CocoaPods, add the IosAwnCore line instead (see iOS)
SwiftAwesomeNotificationsPlugin.setPluginRegistrantCallback in AppDelegate.swift remove it
minSdkVersion 23 minSdk = 24
Flutter 2.5 or later Flutter 3.44 or later

The Messaging, MessagingGroup and MediaPlayer layouts work in the core as they did. The awesome_notifications_chat and awesome_notifications_media packages are optional upgrades of them, with a new model: read their migration sections before adding them.



๐Ÿ”ท Awesome Notification's Flowchart

Notifications are created by your Dart code, by an add-on (a schedule) or by a push package, and shown by native code, so they appear immediately or at their scheduled time, whether your app is running or not.

Awesome Notification's flowchart



โšก๏ธ Notification Events

The events are delivered only after setListeners, and not always at the moment they happen:

  • onNotificationCreatedMethod (optional): a notification was created.
  • onNotificationDisplayedMethod (optional): a notification was displayed.
  • onActionReceivedMethod (required): the user tapped a notification or one of its buttons.
  • onDismissActionReceivedMethod (optional): the user dismissed a notification (some systems don't report every dismissal).

When they are delivered:

Platform App in Foreground App in Background App Terminated (Force Quit)
Android Immediately Immediately Kept, and delivered when the app starts
iOS, macOS Immediately Kept, and delivered when the app comes back Kept, and delivered when the app starts

Windows and the Web follow Android, and Linux delivers the events while the app runs: their limits are in Platform support.

Exception: onActionReceivedMethod is called as soon as the action happens, in any app state, where the platform can start the app for it.



๐Ÿ‘Š Notification Action Types

The actionType of a notification (its body) or of a button:

  • Default: brings the app to the foreground.
  • SilentAction: doesn't bring the app to the foreground; runs on the main isolate, so it can be interrupted if the app is closed.
  • SilentBackgroundAction: doesn't bring the app to the foreground; runs on a separate Dart isolate, with no UI.
  • KeepOnTop: runs the action without closing the notification nor bringing the app to the foreground.
  • DisabledAction: the notification closes, with no action event.
  • DismissAction: dismisses the notification, as the user would, and calls onDismissActionReceivedMethod. It ignores autoDismissible.
  • InputField: deprecated: use requireInputText: true on the button instead.

For the silent types, await all your work inside the method: the isolate may end as soon as the method returns.



๐ŸŸฆ Notification's Category

The category describes the nature of the notification; some systems use it to rank, delay or filter notifications. Always categorize your notifications correctly.

  • Alarm: alarm or timer.
  • Call: incoming call (voice or video) or similar synchronous communication request.
  • Email: asynchronous bulk message (email).
  • Error: error in background operation or authentication status.
  • Event: calendar event.
  • LocalSharing: temporarily sharing location.
  • Message: incoming direct message (SMS, instant message, etc.).
  • MissedCall: a missed incoming call.
  • Navigation: map turn-by-turn navigation.
  • Progress: progress of a long-running background operation.
  • Promo: promotion or advertisement.
  • Recommendation: a specific, timely recommendation for a single thing.
  • Reminder: user-scheduled reminder.
  • Service: indication of running background service.
  • Social: social network or sharing update.
  • Status: ongoing information about device or contextual status.
  • StopWatch: running stopwatch.
  • Transport: media transport control for playback.
  • Workout: tracking a user's workout.


๐Ÿ‘ฎโ€โ™€๏ธ Requesting Permissions

To show any notification, you need the user's consent, and the user can revoke it at any time. On Android 12 and below, the basic permissions are granted to every newly installed app; on iOS, macOS, Android 13 and later and the Web, even the basic permission must be requested. Linux has no permission an app can read: it is granted whenever a notification server runs.

Disclaimer: On Android, revoking some permissions (the notification permission included) makes the system restart the app. Save the state you need before requesting or changing permissions, and restore it when the app starts again.

Permissions are of three types:

  • Normal permissions: not dangerous; no explicit consent needed.
  • Execution permissions: more sensitive; the user must consent explicitly.
  • Special/Dangerous permissions: may harm the user experience or privacy; the user must consent explicitly, and some platforms also require the manufacturer's (Apple's) approval.

Always check that the permissions you need are granted before creating a notification. To know which ones need the user's intervention (a settings page instead of a prompt), call shouldShowRationaleToRequest. Request only what your app needs.


Notification's Permissions:

  • Alert: high-priority notifications that pop up on the screen. Normal-priority ones only show their icon in the status bar.
  • Sound: a sound for each new notification, a few seconds long at most.
  • Badge: a number or dot over the app icon.
  • Light: a blinking LED while the screen is off (only some Android devices have one).
  • Vibration: vibrate for each new notification.
  • FullScreenIntent: show the notification in full screen, even over another app.
  • PreciseAlarms: show scheduled notifications at the exact time. Battery saving modes and some manufacturers may still delay them.
  • CriticalAlert: play the sound even in Do Not Disturb / silent mode (see Critical Alerts).
  • OverrideDnD: lower the Do Not Disturb level to show critical alerts for Alarm and Call notifications. On iOS it comes with CriticalAlert.
  • Provisional: (iOS) show notifications quietly, in Notification Center only, before the user consents.
  • Car: show notifications in car mode.

If requestPermissionToSendNotifications gets no permission list, it requests Alert, Badge, Sound, Vibration and Light.


Notification's Permission Level

A permission lives on one of three levels:

image

  • Device level: settings that apply to every app (all notifications off, battery saving, Do Not Disturb).
  • Application level: settings that apply to every notification of the app.
  • Channel level: settings that apply only to the notifications of one channel.

Critical Alerts

Critical alerts play their sound even in Do Not Disturb / silent mode. They are a channel capability (criticalAlerts: true on the NotificationChannel); there is no per-notification flag.

  • Android: add the ACCESS_NOTIFICATION_POLICY permission to your AndroidManifest.xml, and request NotificationPermission.CriticalAlert (Android 11 and later ask the user's consent).
  • iOS: request the com.apple.developer.usernotifications.critical-alerts entitlement from Apple, add it to the Runner target, and request NotificationPermission.CriticalAlert. Critical alerts by push: see your push package's README.

Without Apple's entitlement or the user's consent, the notifications of a critical channel are shown as standard ones, without errors.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
   <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
   <application>
       ...
   </application>
</manifest>

Full example on how to request permissions

A complete check-and-request, with a rationale dialog when the user must change a setting:

Future<List<NotificationPermission>> requestUserPermissions(
  BuildContext context, {
  // null to request the permissions of the app, not of a channel
  required String? channelKey,
  required List<NotificationPermission> permissionList,
}) async {
  // The basic permission first
  if (!await AwesomeNotifications().isNotificationAllowed() &&
      !await AwesomeNotifications().requestPermissionToSendNotifications()) {
    return [];
  }

  // The permissions already allowed
  var permissionsAllowed = await AwesomeNotifications().checkPermissionList(
      channelKey: channelKey, permissions: permissionList);
  if (permissionsAllowed.length == permissionList.length) {
    return permissionsAllowed;
  }

  // The ones still needed
  final permissionsNeeded =
      permissionList.toSet().difference(permissionsAllowed.toSet()).toList();

  // The ones that need the user's intervention
  final lockedPermissions = await AwesomeNotifications()
      .shouldShowRationaleToRequest(
          channelKey: channelKey, permissions: permissionsNeeded);

  if (lockedPermissions.isEmpty) {
    // Requested directly
    await AwesomeNotifications().requestPermissionToSendNotifications(
        channelKey: channelKey, permissions: permissionsNeeded);
  } else if (context.mounted) {
    // Explained first
    final accepted = await showDialog<bool>(
      context: context,
      builder: (context) => AlertDialog(
        title: const Text('Awesome Notifications needs your permission'),
        content: Text('To proceed, enable: '
            '${lockedPermissions.map((p) => p.name).join(', ')}'),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context, false),
            child: const Text('Deny'),
          ),
          TextButton(
            onPressed: () => Navigator.pop(context, true),
            child: const Text('Allow'),
          ),
        ],
      ),
    );
    if (accepted ?? false) {
      await AwesomeNotifications().requestPermissionToSendNotifications(
          channelKey: channelKey, permissions: lockedPermissions);
    }
  }

  // After the user comes back, the permissions allowed now
  return AwesomeNotifications().checkPermissionList(
      channelKey: channelKey, permissions: permissionList);
}


๐Ÿ“ก Notification channels

Channels group notifications that share settings: name, description, sound, vibration, LED and importance. Create them on initialize, and later with setChannel; at least one channel must exist on initialize. A notification on a channel that doesn't exist (or is disabled) is refused.

On Android 8 (API 26) and later, a channel can't change after its creation, except its name and description. For the exceptional case where you must change one, setChannel with forceUpdate: true deletes it and creates it again under another native key. It closes every notification of that channel: use it only when there is no other way.

The other platforms have no channels of their own: the plugin emulates them, with the same settings, so you write your channels once.

NotificationChannelGroup (on initialize) and channelGroupKey (on the channels) organize the channels in Android's settings. A group's name can change at any time, but a channel joins a group only when it is created.

  • AwesomeNotifications().setChannel: creates or updates a channel.
  • AwesomeNotifications().removeChannel: removes a channel and closes its notifications.

Notification Channel Attributes

Attribute Required Description Type Updatable Default Value
channelKey Yes A string key that identifies a channel where notifications are sent. String No -
channelName Yes The name of the channel, which is visible to users on Android. String Yes -
channelDescription Yes A brief description of the channel, which is visible to users on Android. String Yes -
channelShowBadge No Whether the notification should automatically increment the app icon badge counter. Boolean Yes false
channelGroupKey No A string key to group all channels in same topic at android's configuration page String No -
importance No The importance level of the notification. NotificationImportance No Default
playSound No Whether the notification should play a sound. Boolean No true
soundSource No The path of a custom sound file to be played with the notification. String No -
defaultRingtoneType No The type of default sound to be played with the notification (only for Android). DefaultRingtoneType Yes Notification
enableVibration No Whether the device should vibrate when the notification is received. Boolean No true
vibrationPattern No A custom vibration pattern (only for Android). Int64List No -
enableLights No Whether the device should display a blinking LED when the notification is received. Boolean No true
ledColor No The color of the LED to display when the notification is received. Color No Colors.white
ledOnMs No The duration in milliseconds that the LED should remain on when displaying the notification. Integer No -
ledOffMs No The duration in milliseconds that the LED should remain off when displaying the notification. Integer No -
groupKey No The string key used to group notifications together in Android status bar. String No -
groupSort No The order in which notifications within a group should be sorted. GroupSort No Desc
groupAlertBehavior No The alert behavior to use for notifications within a group. GroupAlertBehavior No All
defaultPrivacy No The level of privacy to apply to the notification when the device is locked. NotificationPrivacy No Private
icon No The name of the notification icon to display in the status bar. String No -
defaultColor No The color to use for the notification on Android. Color No Colors.black
locked No Whether the notification should be prevented from being dismissed by the user. Boolean No false
onlyAlertOnce No Whether the notification should only alert the user once. Boolean No false
criticalAlerts No Whether the channel's notifications are critical alerts (see Critical Alerts). Boolean No false


๐Ÿ”ด App Badge

The app badge counter works on every platform, as on iOS: Android, macOS and the Web show it on the app icon (where the launcher or browser supports it); Windows and Linux keep the counter, but don't show it yet.

  • getGlobalBadgeCounter / setGlobalBadgeCounter(amount): read or set the counter.
  • incrementGlobalBadgeCounter / decrementGlobalBadgeCounter: change it by one.
  • resetGlobalBadge: set it to zero.
  • channelShowBadge: true on a channel increments the counter for each new notification of that channel; badge on a notification sets the counter to that value.


โฑ Chronometer and Timeout (Expiration)

chronometer (a Duration) shows a running chronometer, starting from that value. timeoutAfter (a Duration) dismisses the notification by itself after that time. In push payloads, both are positive integers (seconds).

await AwesomeNotifications().createNotification(
  content: NotificationContent(
    id: 11,
    channelKey: 'basic_channel',
    title: 'Notification with Chronometer and Timeout',
    body: 'Starts a chronometer and closes itself after 20 seconds',
    chronometer: Duration.zero, // counts from 0 seconds
    timeoutAfter: const Duration(seconds: 20), // dismissed after 20 seconds
  ),
);


โŒ›๏ธ Progress Bar Notifications

The ProgressBar layout shows a progress bar on Android (the Web shows the percentage). Set progress (0 to 100), or leave it null for an indeterminate bar. To update it, create the notification again with the same id, at most once per second: faster updates may be blocked by the system.

Future<void> showProgressNotification(int id) async {
  const maxStep = 10;
  for (var step = 0; step <= maxStep; step++) {
    final progress = (step / maxStep * 100).round();
    final done = step == maxStep;
    await AwesomeNotifications().createNotification(
      content: NotificationContent(
        id: id,
        channelKey: 'progress_bar',
        title: done ? 'Download finished' : 'Downloading file ($progress%)',
        body: 'filename.txt',
        category: NotificationCategory.Progress,
        notificationLayout:
            done ? NotificationLayout.Default : NotificationLayout.ProgressBar,
        progress: done ? null : progress.toDouble(),
        locked: !done, // the user can't dismiss it while it runs
      ),
    );
    if (!done) await Future.delayed(const Duration(seconds: 1));
  }
}


๐Ÿ˜ƒ Emojis (Emoticons)

The Emojis class has more than 3000 emojis to concatenate with your text. In push payloads, use the emoji's Unicode text (from the full emoji list), for example \u{1f6f8}. Not every emoji is shown on every platform: test the ones you use.

await AwesomeNotifications().createNotification(
  content: NotificationContent(
    id: 12,
    channelKey: 'basic_channel',
    title: 'Emojis are awesome too! ${Emojis.smile_face_with_tongue}'
        '${Emojis.smile_rolling_on_the_floor_laughing}${Emojis.emotion_red_heart}',
    body: 'Simple body with a bunch of Emojis! ${Emojis.transport_police_car} '
        '${Emojis.animals_dog} ${Emojis.flag_UnitedStates} ${Emojis.person_baby}',
    bigPicture: 'https://tecnoblog.net/wp-content/uploads/2019/09/emoji.jpg',
    notificationLayout: NotificationLayout.BigPicture,
  ),
);


๐ŸŽจ Notification Layout Types

  • Default: the default layout, also used when the chosen one can't be shown.
  • BigPicture: a large picture, next to a small image.
  • BigText: more than two lines of text.
  • Inbox: a list of messages or items, one per line.
  • ProgressBar: a progress bar, such as a download's.
  • Messaging: a chat conversation with one person (awesome_notifications_chat gives it real conversations).
  • MessagingGroup: a chat conversation with a group.
  • MediaPlayer: a media controller with buttons (awesome_notifications_media gives it the system's media controls).

Where a platform has no such layout, it shows the notification with the default layout.



๐Ÿ“ท Media Source Types

Images take a prefix that says where they come from:

  • asset://: a Flutter asset. Example: asset://assets/images/balloons.png
  • http(s)://: a network image. Example: https://url.com/to/image.png
  • file://: a file on the device. Example: file://path/to/image.png
  • resource://: an Android native resource, in android/app/src/main/res/drawable. Example: resource://drawable/res_image

Icons and sounds can only be resources. The Web loads only https:// and asset:// images.



โฌ†๏ธ Notification Importance

The importance of a channel, from the most to the least important:

  • Max: makes a sound and appears as a heads-up notification.
  • High: shows everywhere, makes noise and peeks. May use full-screen intents.
  • Default: shows everywhere, makes noise, but does not visually intrude.
  • Low: shows in the shade, and possibly in the status bar, but makes no sound.
  • Min: only shows in the shade, below the fold.
  • None: disables the channel.

Use the higher levels only for critical or time-sensitive notifications: abusing them annoys the user. Like the rest of a channel, the importance can't change after its creation.



๐Ÿ”† Wake Up Screen Notifications

wakeUpScreen: true turns the screen on for the notification, even when the device is locked. On Android, add the WAKE_LOCK permission and android:turnScreenOn="true" on your activity:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
   <uses-permission android:name="android.permission.WAKE_LOCK" />
   <application>
        <activity
            android:name=".MainActivity"
            android:turnScreenOn="true">
            ...
        </activity>
   </application>
</manifest>


๐Ÿ–ฅ Full Screen Notifications (Android)

fullScreenIntent: true shows the notification in full screen, even when the device is locked. Android may open your app by itself when it shows the notification, as if the user tapped it, so your app can show a full screen page; you can't control when that happens.

Add the USE_FULL_SCREEN_INTENT permission and android:showOnLockScreen="true" on your activity. On Android 11 and later, request NotificationPermission.FullScreenIntent too.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
   <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
   <application>
       <activity
            android:name=".MainActivity"
            android:showOnLockScreen="true">
           ...
       </activity>
   </application>
</manifest>


๐Ÿ—‚ Managing Notifications

Every method below works on every platform (where a platform can't do it, it answers "unavailable" instead of throwing):

Method What it does
dismiss(id) Closes a notification shown, keeping its schedule
dismissNotificationsByChannelKey(key) / dismissNotificationsByGroupKey(key) Closes the notifications of a channel / group
dismissAllNotifications() Closes every notification shown
cancel(id) Closes a notification and removes its schedule
cancelNotificationsByChannelKey(key) / cancelNotificationsByGroupKey(key) The same, for a channel / group
cancelAll() Closes every notification and removes every schedule
isNotificationActiveOnStatusBar(id: id) Whether a notification is on screen
getAllActiveNotificationIdsOnStatusBar() The ids of the notifications on screen
getAppLifeCycle() Whether the app is in foreground, background or was terminated
getLocalTimeZoneIdentifier() / getUtcTimeZoneIdentifier() The device's time zone, and UTC
showNotificationConfigPage(channelKey: key) Opens the system settings of the app's (or a channel's) notifications
showAlarmPage() Opens the precise alarms settings (Android)
showGlobalDndOverridePage() Opens the Do Not Disturb access settings (Android)

The schedules themselves (listing them, cancelling only the schedule) are in awesome_notifications_schedules.



๐Ÿงฉ Add-on Packages

Each feature beyond showing a notification is a package of its own. Add only the ones you use; each README has its setup, API and platform notes:

Package What it adds
awesome_notifications_schedules Notifications at a date, at intervals or on calendar rules, with time zones and precise alarms
awesome_notifications_localizations The same notification in several languages, shown in the language you choose
awesome_notifications_chat Conversations with people, avatars and replies (iOS communication notifications)
awesome_notifications_media The system's media player controls
awesome_notifications_calls Incoming calls (CallKit, Android CallStyle, VoIP pushes)
awesome_notifications_live_activities iOS Live Activities and Android Live Updates
awesome_notifications_foreground_service Android foreground services, shown as a notification
awesome_notifications_fcm Push notifications through Firebase Cloud Messaging (Android, iOS, macOS, Web)
awesome_notifications_wns Push notifications through WNS (Windows)
awesome_notifications_unifiedpush Push notifications through UnifiedPush (Android, Linux)
awesome_notifications_onesignal OneSignal pushes, next to onesignal_flutter (Android, iOS)
awesome_notifications_braze Braze pushes, next to braze_plugin (Android, iOS)
awesome_notifications_airship Airship pushes, next to airship_flutter (Android, iOS)


๐Ÿ“จ Push Notifications

The core shows the pushes the push packages receive, exactly as local notifications (channels, layouts, buttons, images, the four events and the add-ons). Add the package of each push service you use; its README has the setup, the payload and how it handles repeated pushes:

Package Platforms Push service
awesome_notifications_fcm Android, iOS, macOS, Web Firebase Cloud Messaging
awesome_notifications_wns Windows Windows Push Notification Services
awesome_notifications_unifiedpush Android, Linux UnifiedPush
awesome_notifications_onesignal Android, iOS OneSignal (with its official plugin)
awesome_notifications_braze Android, iOS Braze (with its official plugin)
awesome_notifications_airship Android, iOS Airship (with its official plugin)


๐Ÿ— Notification Structures

The structures of a notification, as Dart objects and as the keys of a push payload. The add-on packages add their own (schedule in awesome_notifications_schedules, localizations in awesome_notifications_localizations, and so on), documented in their READMEs.

NotificationContent ("content" in Push data) - (required)

Attribute Required Description Type Value Limits Default value
id YES A unique identifier for the notification int 1 - 2,147,483,647 -
channelKey YES The identifier of the notification channel where the notification will be displayed String Channel must be enabled -
title NO The title of the notification String Unlimited -
body NO The body text of the notification String Unlimited -
titleLocKey NO Key to a localized title string with placeholders, to be replaced by titleLocArgs String Unlimited -
bodyLocKey NO Key to a localized body string with placeholders, to be replaced by bodyLocArgs String Unlimited -
titleLocArgs NO Arguments to replace placeholders in the localized title string, referenced by titleLocKey List Unlimited -
bodyLocArgs NO Arguments to replace placeholders in the localized body string, referenced by bodyLocKey List Unlimited -
summary NO A summary to be displayed when the notification content is protected by privacy String Unlimited -
groupKey NO Groups the notifications with the same key String Unlimited -
category NO The notification category that best describes the nature of the notification NotificationCategory - -
badge NO The value to display as the app's badge int 0 - 999,999 -
chronometer NO Shows a chronometer, starting from this value Duration Positive integers -
timeoutAfter NO Dismisses the notification by itself after this time Duration Positive integers -
showWhen NO Whether to show the time elapsed since the notification was posted bool True or false true
displayOnForeground NO Whether to display the notification while the app is in the foreground bool True or false true
displayOnBackground NO Whether to display the notification while the app is in the background bool True or false true
icon NO The small icon of the notification (Android) String A resource image -
largeIcon NO The large icon of the notification String Unlimited -
bigPicture NO The image displayed by the BigPicture layout String Unlimited -
roundedLargeIcon NO Whether to show the large icon as a circle bool True or false false
roundedBigPicture NO Whether to show the big picture as a circle bool True or false false
customSound NO A sound resource for this notification String A resource sound -
wakeUpScreen NO Turns the screen on (see Wake Up Screen Notifications) bool True or false false
fullScreenIntent NO Shows the notification in full screen (see Full Screen Notifications) bool True or false false
autoDismissible NO Whether to dismiss the notification when the user taps it bool True or false true
color NO The accent color of the notification Color 0x000000 to 0xFFFFFF -
backgroundColor NO The background color of the notification Color 0x000000 to 0xFFFFFF -
payload NO Hidden data, delivered with the events Map<String, String?> Only string values -
notificationLayout NO The layout type for the notification NotificationLayout - Default
hideLargeIconOnExpand NO Whether to hide the large icon when the notification is expanded (Android) bool True or false false
locked NO Whether to prevent the user from dismissing the notification (Android) bool True or false false
progress NO The value of the progress bar (null for an indeterminate bar) double 0.0 - 100.0 -
ticker NO The text for accessibility services when the notification arrives String Unlimited -
duration NO The media duration on media player notifications Duration Unlimited -
playState NO The current playback state on media player notifications NotificationPlayState - -
playbackSpeed NO The playback speed on media player notifications: 1.0 is normal, 0 when paused, negative when rewinding double Unlimited -
actionType NO What a tap on the body of the notification does (see Notification Action Types) ActionType - Default

NotificationActionButton ("actionButtons" in Push data) - (optional)

Attribute Required Description Type Value Limits Default value
key YES A text key that identifies what action the user took when they tapped the button String unlimited -
label YES The text to be displayed on the action button String unlimited -
icon NO The icon to be displayed inside the button (only available for few layouts) String Must be a resource image -
color NO The label text color (Android) Color 0x000000 to 0xFFFFFF -
enabled NO On Android, deactivates the button. On iOS, the button disappears bool true or false true
requireInputText NO Asks the user to type a reply, delivered in buttonKeyInput bool true or false false
autoDismissible NO Whether the notification should be dismissed when the user taps the button bool true or false true
showInCompactView NO For MediaPlayer notifications on Android, sets the button as visible in compact view bool true or false false
isDangerousOption NO Whether the button is marked as a dangerous option, displaying the text in red bool true or false false
isAuthenticationRequired NO The action performed by this button requires user authentication to proceed bool true or false false
actionType NO What a tap on the button does ActionType - Default


๐Ÿ“ฑ Example Apps

Every package has one example app, a single main.dart you can copy into a new project:

  1. Create a new Flutter project for the platforms you want (flutter create my_app).
  2. Copy the package's example (for this core, pub.dev/packages/awesome_notifications/example) into lib/main.dart.
  3. Add the packages it imports to your pubspec.yaml.
  4. Run it on a device, an emulator, your desktop or your browser.

To run them from the source code, clone the repository, run flutter pub get at its root and run the example/ folder of each package under packages/.



๐Ÿฉบ Common Known Issues

Issue: Notification is not showing up or is showing up inconsistently

Fix: Check, in this order:

  • The permission: isNotificationAllowed(), and the channel's settings in the system (showNotificationConfigPage(channelKey: ...)).
  • The channel: it exists (created on initialize or setChannel) and isn't disabled; a notification on an unknown channel is refused, with an error printed when debug: true.
  • displayOnForeground / displayOnBackground: they hide the notification in that app state.
  • Battery optimization, which may delay or drop notifications on some Android devices (for schedules, see the precision notes of awesome_notifications_schedules).


Issue: Invalid notification content

Fix: Each element of a notification must have the type in Notification Structures; an invalid one makes the notification be refused. The payload values must be strings.



๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guide before submitting a pull request.

Important: All pull requests must target the development branch. PRs aimed at master will be rejected.



๐Ÿ’ฐ Donate via Stripe or BuyMeACoffee

Help us improve and maintain our work with donations of any amount via Stripe or BuyMeACoffee. Your donation will mainly be used to purchase new devices and equipment, which we will use to test and ensure that our plugins work correctly on all platforms and their respective versions.

Donate With Stripe Donate With Buy Me A Coffee



๐Ÿ’ฌ Discord Chat Server

Stay up to date with new updates and get community support by subscribing to our Discord chat server:

Discord Banner 3



โœ… Next steps

  • Push providers that complement the family where Firebase Cloud Messaging doesn't reach: Huawei Push Kit (HMS).
  • Linux: taps and buttons with the app closed, through a small helper bundled with the app.

We are constantly working to improve Awesome Notifications and provide support for new platforms and services. Stay tuned for more updates!