requestPermission method

  1. @override
Future<NotificationSettings> requestPermission({
  1. bool alert = true,
  2. bool announcement = false,
  3. bool badge = true,
  4. bool carPlay = false,
  5. bool criticalAlert = false,
  6. bool provisional = false,
  7. bool sound = true,
})

Prompts the user for notification permissions.

On iOS, a dialog is shown requesting the users permission. If provisional is set to true, silent notification permissions will be automatically granted. When notifications are delivered to the device, the user will be presented with an option to disable notifications, keep receiving them silently or enable prominent notifications.

On Android, is it not required to call this method. If called however, a NotificationSettings class will be returned with NotificationSettings.authorizationStatus returning AuthorizationStatus.authorized.

On Web, a popup requesting the users permission is shown using the native browser API.

Implementation

@override
Future<NotificationSettings> requestPermission({
  bool alert = true,
  bool announcement = false,
  bool badge = true,
  bool carPlay = false,
  bool criticalAlert = false,
  bool provisional = false,
  bool sound = true,
}) {
  return convertWebExceptions(() async {
    String status =
        (await web.Notification.requestPermission().toDart) as String;
    return utils.getNotificationSettings(status);
  });
}