requestPermissions static method

Future<bool?> requestPermissions({
  1. bool sound = true,
  2. bool alert = true,
  3. bool badge = true,
})

Implementation

static Future<bool?> requestPermissions({
  bool sound = true,
  bool alert = true,
  bool badge = true,
}) async {
  if (!kIsWeb && Platform.isIOS) {
    return await FlutterLocalNotificationsPlugin()
        .resolvePlatformSpecificImplementation<
            IOSFlutterLocalNotificationsPlugin>()
        ?.requestPermissions(
          alert: sound,
          badge: badge,
          sound: sound,
        );
  } else if (!kIsWeb && Platform.isMacOS) {
    return await FlutterLocalNotificationsPlugin()
        .resolvePlatformSpecificImplementation<
            MacOSFlutterLocalNotificationsPlugin>()
        ?.requestPermissions(
          alert: sound,
          badge: badge,
          sound: sound,
        );
  } else if (!kIsWeb && Platform.isAndroid) {
    return await FlutterLocalNotificationsPlugin()
        .resolvePlatformSpecificImplementation<
            AndroidFlutterLocalNotificationsPlugin>()
        ?.requestPermission();
  } else {
    return null;
  }
}