setListeners method

  1. @override
Future<bool> setListeners({
  1. required ActionHandler onActionReceivedMethod,
  2. NotificationHandler? onNotificationCreatedMethod,
  3. NotificationHandler? onNotificationDisplayedMethod,
  4. ActionHandler? onDismissActionReceivedMethod,
})
override

Defines the global or static methods that will receive notification events. Only after set at least one method, the notification's events will be delivered. These methods require to use the notation @pragma("vm:entry-point")

The onActionReceivedMethod parameter is a function that receives all the notification actions that are triggered by the user.

The optional onNotificationCreatedMethod parameter is a function that is called when a new notification or schedule is created on the system.

The optional onNotificationDisplayedMethod parameter is a function that is called when a new notification is displayed on the status bar.

The optional onDismissActionReceivedMethod parameter is a function that receives the notification dismiss actions.

This method returns a Future that resolves to true if the listeners were successfully set, or false if an error occurred.

Implementation

@override
Future<bool> setListeners(
    {required ActionHandler onActionReceivedMethod,
    NotificationHandler? onNotificationCreatedMethod,
    NotificationHandler? onNotificationDisplayedMethod,
    ActionHandler? onDismissActionReceivedMethod}) {
  return AwesomeNotificationsPlatform.instance.setListeners(
    onActionReceivedMethod: onActionReceivedMethod,
    onNotificationCreatedMethod: onNotificationCreatedMethod,
    onNotificationDisplayedMethod: onNotificationDisplayedMethod,
    onDismissActionReceivedMethod: onDismissActionReceivedMethod,
  );
}