useLocalNotifications method

void useLocalNotifications({
  1. DarwinInitializationSettings? iosSettings,
  2. AndroidInitializationSettings? androidSettings,
  3. LinuxInitializationSettings? linuxSettings,
  4. dynamic onDidReceiveLocalNotification(
    1. NotificationResponse details
    )?,
  5. dynamic onDidReceiveBackgroundNotificationResponse(
    1. NotificationResponse details
    )?,
})

Use local notifications

Implementation

void useLocalNotifications({
  DarwinInitializationSettings? iosSettings,
  AndroidInitializationSettings? androidSettings,
  LinuxInitializationSettings? linuxSettings,
  Function(NotificationResponse details)? onDidReceiveLocalNotification,
  Function(NotificationResponse details)?
      onDidReceiveBackgroundNotificationResponse,
}) {
  _useLocalNotifications = true;

  late InitializationSettings initializationSettings;
  if (Platform.isAndroid) {
    initializationSettings = InitializationSettings(
      android: androidSettings ?? AndroidInitializationSettings('app_icon'),
    );
  }
  if (Platform.isIOS || Platform.isMacOS) {
    initializationSettings = InitializationSettings(
      iOS: iosSettings ?? const DarwinInitializationSettings(),
    );
  }
  if (Platform.isLinux) {
    initializationSettings = InitializationSettings(
      linux: linuxSettings ??
          const LinuxInitializationSettings(
              defaultActionName: 'Open notification'),
    );
  }

  _initializationSettings = initializationSettings;
  _onDidReceiveLocalNotification = onDidReceiveLocalNotification;
  _onDidReceiveBackgroundNotificationResponse =
      onDidReceiveBackgroundNotificationResponse;
}