DefaultNotificationHandler class
Default NotificationWrapper implementation backed by AwesomeNotifications for display and Firebase Cloud Messaging for delivery.
Use initializeSharedInstance once at app startup, then access the shared handler via DefaultNotificationHandler.I.
- Inheritance
-
- Object
- NotificationWrapper
- DefaultNotificationHandler
Properties
- debugConfig → NotificationConfig?
-
The currently active config (fallback config in a background isolate).
Test-only.
no setter
-
handleActionReceived
→ Future<
void> Function(ReceivedAction) -
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onActionReceived
→ Stream<
ReceivedAction> -
User interactions (taps / action buttons) on AwesomeNotifications.
no setteroverride
-
onBackgroundMessage
→ Future<
void> Function(RemoteMessage) -
finalinherited
- onError → void Function(Object error, StackTrace stackTrace)?
-
Called when an internal operation throws. Receives the raw
errorand itsstackTrace. The error is not downcast, so any error type is delivered safely (never rethrown from inside the package's catch blocks).finalinherited -
onForegroundMessage
→ Stream<
RemoteMessage> -
Foreground FCM messages.
no setteroverride
- onMessage → void Function(RemoteMessage)
-
finalinherited
-
onMessageOpened
→ Stream<
RemoteMessage> -
FCM messages whose notification was tapped to bring the app to the
foreground (from background, not terminated — see getInitialMessage).
no setteroverride
- onMessageOpenedApp → void Function(RemoteMessage)
-
finalinherited
-
onNotificationCreated
→ Future<
void> Function(ReceivedNotification) -
finalinherited
-
onNotificationDismissed
→ Future<
void> Function(ReceivedAction) -
finalinherited
-
onNotificationDisplayed
→ Future<
void> Function(ReceivedNotification) -
finalinherited
-
onPermissionEvent
→ void Function(String name, Map<
String, Object?> parameters)? -
Optional analytics seam. Invoked for notable events (e.g. permission
requests) so the host app can log them through its own analytics pipeline,
after obtaining user consent. The package itself logs nothing externally.
finalinherited
-
onTokenRefresh
→ Stream<
String> -
FCM device-token refreshes. Send the new token to your server here.
no setteroverride
- permissionStatus → AuthorizationStatus
-
The most recently observed notification authorization status.
no setter
-
permissionStatusStream
→ Stream<
AuthorizationStatus> -
Emits whenever permissionStatus changes.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelAllNotifications(
) → Future< void> -
override
-
cancelNotification(
int id) → Future< void> -
override
-
clearBadgeCount(
) → Future< void> -
override
-
dispose(
) → void -
Cancels listeners, closes streams and releases resources. Call when the
handler is no longer needed (e.g. on logout or app teardown).
override
-
getFcmToken(
) → Future< String?> -
override
-
getInitialAction(
) → Future< ReceivedAction?> -
The notification action that launched the app from a terminated state, or
null. Use to deep-link from a tapped local notification on cold start.override -
getInitialMessage(
) → Future< RemoteMessage?> -
The FCM message that launched the app from a terminated state by tapping
its notification, or
nullif the app was not launched that way. Call once after initialize to deep-link from a cold start.override -
initialize(
{NotificationConfig? config, FirebaseOptions? firebaseOptions, bool requestPermissionsOnInit = false}) → Future< void> -
Initializes channels, listeners and (optionally) Firebase.
override
-
isNotificationAllowed(
) → Future< bool> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openNotificationSettings(
) → Future< void> -
override
-
requestPermissions(
) → Future< AuthorizationStatus> -
override
-
scheduleNotification(
{required int id, required String title, required String body, required DateTime scheduledDate, Map< String, String> ? payload, String? channelKey}) → Future<int?> -
override
-
showActionNotification(
{required String title, required String body, List< NotificationActionButton> ? buttons, Map<String, String> ? payload, String? channelKey}) → Future<int?> -
override
-
showBigPictureNotification(
{required String title, required String body, required String bigPicture, String? largeIcon, Map< String, String> ? payload, String? channelKey}) → Future<int?> -
Shows a big-picture notification.
bigPictureis an AwesomeNotifications resource (e.g.asset://...,resource://...,file://..., or a URL).override -
showGroupedNotification(
String groupKey, List< NotificationContent> messages) → Future<List< int> > -
override
-
showNotification(
RemoteMessage message) → Future< int?> -
override
-
showRegularNotification(
{required String title, required String body, Map< String, String> ? payload, String? channelKey}) → Future<int?> -
override
-
showReplyNotification(
{required String title, required String body, String? replyLabel, NotificationActionButton? replyButton, Map< String, String> ? payload, String? channelKey}) → Future<int?> -
override
-
simulateNotification(
{required String title, required String body, Map< String, dynamic> ? data, String? channelKey}) → Future<int?> -
override
-
subscribeToTopic(
String topic) → Future< void> -
override
-
toString(
) → String -
A string representation of this object.
inherited
-
unsubscribeFromTopic(
String topic) → Future< void> -
override
-
updateBadgeCount(
int count) → Future< void> -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- I → DefaultNotificationHandler
-
The shared handler instance.
no setter
Static Methods
-
createForTest(
{required AwesomeNotifications awesomeNotifications, FirebaseMessaging? firebaseMessaging, NotificationConfig? config, void onError(Object error, StackTrace stackTrace)?}) → DefaultNotificationHandler - Creates an instance wired to injected plugins and registers it as the shared singleton, without running initialize. Test-only.
-
debugGenerateId(
) → int - Exposes the internal monotonic id generator for tests.
-
debugStableId(
String? key) → int - Exposes the internal stable-id derivation for tests.
- Creates and initializes the shared instance. Call once at startup.
-
resetInstance(
) → void - Resets the singleton. Test-only.
-
smartDefaultBackgroundMessageHandler(
RemoteMessage message) → Future< void> - Default background handler. Always displays via AwesomeNotifications for consistent behavior across Android versions, especially Android 13+ (API 33+) where FCM auto-display requires POST_NOTIFICATIONS and silently fails without it.