initialize method

  1. @override
Future<bool> initialize(
  1. String? defaultIcon,
  2. List<NotificationChannel> channels, {
  3. List<NotificationChannelGroup>? channelGroups,
  4. bool debug = false,
})
override

Initializes the plugin by creating a default icon and setting up the initial notification channels. This method only needs to be called once in the main.dart file of your application.

The defaultIcon parameter specifies the resource media type of the default icon that will be used for notifications. This should be a String representing the resource name.

The channels parameter is a list of NotificationChannel objects that represent the initial notification channels to be created. If any of the channels already exist, they will be updated with the provided information.

The optional channelGroups parameter is a list of NotificationChannelGroup objects that are used to organize the channels visually in Android's notification configuration page.

The optional debug parameter enables verbose logging in Awesome Notifications.

This method returns a Future that resolves to true if the initialization was successful, or false if an error occurred.

Implementation

@override
Future<bool> initialize(
  String? defaultIcon,
  List<NotificationChannel> channels, {
  List<NotificationChannelGroup>? channelGroups,
  bool debug = false,
}) async {
  AwesomeNotifications.localTimeZoneIdentifier = engine.api.localTimeZone;
  AwesomeNotifications.utcTimeZoneIdentifier = 'GMT';
  return engine.initialize([for (final channel in channels) channel.toMap()]);
}