localNotifications static method

Future<void> localNotifications(
  1. dynamic callback(
    1. FlutterLocalNotificationsPlugin localNotifications
    )
)

Get the local notifications plugin

Implementation

static Future<void> localNotifications(
  Function(FlutterLocalNotificationsPlugin localNotifications) callback,
) async {
  Nylo nylo = Nylo.instance;
  FlutterLocalNotificationsPlugin? flutterLocalNotifications = nylo
      .getLocalNotifications();
  if (flutterLocalNotifications == null) {
    flutterLocalNotifications = FlutterLocalNotificationsPlugin();
    nylo.setLocalNotifications(flutterLocalNotifications);
  }
  if (nylo.isFlutterLocalNotificationsInitialized) {
    await callback(flutterLocalNotifications);
    return;
  }
  nylo.isFlutterLocalNotificationsInitialized =
      await flutterLocalNotifications.initialize(
        settings:
            nylo.getInitializationSettings() ?? InitializationSettings(),
        onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
        onDidReceiveNotificationResponse: onDidReceiveNotificationResponse,
      ) ??
      false;
  await callback(flutterLocalNotifications);
}