initialize method

  1. @override
Future<void> initialize()
override

Initialize and set up the notification controller. Also tries to get permissions to send notifications.

Implementation

@override
Future<void> initialize() async {
  AwesomeNotifications().initialize(
    null,
    [
      NotificationChannel(
        channelKey: 'basic_channel',
        channelName: 'Basic Notifications',
        channelDescription: "Basic Notifications",
        importance: NotificationImportance.High,
        channelShowBadge: true,
      ),
      NotificationChannel(
        channelKey: 'scheduled_channel',
        channelName: 'Scheduled Notifications',
        channelDescription: "Scheduled Notifications",
        locked: true,
        importance: NotificationImportance.High,
        channelShowBadge: true,
      ),
    ],
  );

  // ask for permissions to use notifications
  AwesomeNotifications().isNotificationAllowed().then((isAllowed) {
    if (!isAllowed) {
      AwesomeNotifications().requestPermissionToSendNotifications();
    }
  });
  info('$runtimeType initialized.');
}