# Class NotificationPermissionRequest

java.lang.Object
com.codename1.notifications.NotificationPermissionRequest

public class NotificationPermissionRequest extends java.lang.Object

Describes which notification capabilities an app wants to request when calling `com.codename1.ui.Display#requestNotificationPermission(NotificationPermissionRequest, NotificationPermissionCallback)`.

By default `alert`, `sound` and `badge` are requested. Additional options such as `provisional`, `critical`, `timeSensitive`, `carPlay` and `announcement` map to iOS `UNAuthorizationOptions`. On Android only the existence of any requested capability matters; the granular options that have no Android equivalent are ignored.

Usage

    NotificationPermissionRequest req = new NotificationPermissionRequest()
            .provisional(true)
            .timeSensitive(true);
    Display.getInstance().requestNotificationPermission(req, result -> {
        if (result.isGranted()) {
            // schedule notifications
        }
    });

##### See also

- NotificationPermissionCallback

- NotificationPermissionResult

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NotificationPermissionRequest()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `NotificationPermissionRequest`
  `alert(boolean b)`
  Requests permission to display alerts.
  `NotificationPermissionRequest`
  `announcement(boolean b)`
  Requests permission for Siri to read out notifications (iOS).
  `NotificationPermissionRequest`
  `badge(boolean b)`
  Requests permission to update the app icon badge.
  `NotificationPermissionRequest`
  `carPlay(boolean b)`
  Requests permission to display notifications in CarPlay (iOS).
  `NotificationPermissionRequest`
  `critical(boolean b)`
  Requests permission to send critical alerts (iOS).
  `boolean`
  `isAlert()`
  Returns true if alert permission is requested.
  `boolean`
  `isAnnouncement()`
  Returns true if announcement permission is requested.
  `boolean`
  `isBadge()`
  Returns true if badge permission is requested.
  `boolean`
  `isCarPlay()`
  Returns true if CarPlay permission is requested.
  `boolean`
  `isCritical()`
  Returns true if critical alert permission is requested.
  `boolean`
  `isProvidesAppSettings()`
  Returns true if the app advertises in-app notification settings.
  `boolean`
  `isProvisional()`
  Returns true if provisional authorization is requested.
  `boolean`
  `isSound()`
  Returns true if sound permission is requested.
  `boolean`
  `isTimeSensitive()`
  Returns true if the time sensitive interruption level is requested.
  `NotificationPermissionRequest`
  `providesAppSettings(boolean b)`
  Requests that the app provide its own in-app notification settings (iOS).
  `NotificationPermissionRequest`
  `provisional(boolean b)`
  Requests provisional authorization (iOS).
  `NotificationPermissionRequest`
  `sound(boolean b)`
  Requests permission to play notification sounds.
  `NotificationPermissionRequest`
  `timeSensitive(boolean b)`
  Requests the ability to mark notifications as time sensitive (iOS).
  `int`
  `toAuthorizationOptionsMask()`
  Converts this request into the bitmask consumed by the iOS native layer.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### NotificationPermissionRequest

    public NotificationPermissionRequest()

- ## Method Details

  - ### alert

    public NotificationPermissionRequest alert(boolean b)

    Requests permission to display alerts. Enabled by default.

    ###### Parameters

    - `b`: true to request alert permission

    ###### Returns

    this request for chaining

  - ### sound

    public NotificationPermissionRequest sound(boolean b)

    Requests permission to play notification sounds. Enabled by default.

    ###### Parameters

    - `b`: true to request sound permission

    ###### Returns

    this request for chaining

  - ### badge

    public NotificationPermissionRequest badge(boolean b)

    Requests permission to update the app icon badge. Enabled by default.

    ###### Parameters

    - `b`: true to request badge permission

    ###### Returns

    this request for chaining

  - ### provisional

    public NotificationPermissionRequest provisional(boolean b)

    Requests provisional authorization (iOS). Provisional notifications are delivered quietly to the notification center without an explicit prompt. Ignored on platforms that do not support it.

    ###### Parameters

    - `b`: true to request provisional authorization

    ###### Returns

    this request for chaining

  - ### critical

    public NotificationPermissionRequest critical(boolean b)

    Requests permission to send critical alerts (iOS). Critical alerts bypass Do Not Disturb and the mute switch and require a special Apple entitlement. Without the entitlement the request is silently downgraded. Ignored on platforms that do not support it.

    ###### Parameters

    - `b`: true to request critical alert permission

    ###### Returns

    this request for chaining

  - ### timeSensitive

    public NotificationPermissionRequest timeSensitive(boolean b)

    Requests the ability to mark notifications as time sensitive (iOS). Ignored on platforms that do not support it.

    ###### Parameters

    - `b`: true to request the time sensitive interruption level

    ###### Returns

    this request for chaining

  - ### carPlay

    public NotificationPermissionRequest carPlay(boolean b)

    Requests permission to display notifications in CarPlay (iOS). Ignored elsewhere.

    ###### Parameters

    - `b`: true to request CarPlay permission

    ###### Returns

    this request for chaining

  - ### announcement

    public NotificationPermissionRequest announcement(boolean b)

    Requests permission for Siri to read out notifications (iOS). Ignored elsewhere.

    ###### Parameters

    - `b`: true to request announcement permission

    ###### Returns

    this request for chaining

  - ### providesAppSettings

    public NotificationPermissionRequest providesAppSettings(boolean b)

    Requests that the app provide its own in-app notification settings (iOS). Ignored elsewhere.

    ###### Parameters

    - `b`: true to advertise in-app notification settings

    ###### Returns

    this request for chaining

  - ### isAlert

    public boolean isAlert()

    Returns true if alert permission is requested.

    ###### Returns

    true if alerts are requested

  - ### isSound

    public boolean isSound()

    Returns true if sound permission is requested.

    ###### Returns

    true if sound is requested

  - ### isBadge

    public boolean isBadge()

    Returns true if badge permission is requested.

    ###### Returns

    true if badge is requested

  - ### isProvisional

    public boolean isProvisional()

    Returns true if provisional authorization is requested.

    ###### Returns

    true if provisional authorization is requested

  - ### isCritical

    public boolean isCritical()

    Returns true if critical alert permission is requested.

    ###### Returns

    true if critical alerts are requested

  - ### isTimeSensitive

    public boolean isTimeSensitive()

    Returns true if the time sensitive interruption level is requested.

    ###### Returns

    true if time sensitive notifications are requested

  - ### isCarPlay

    public boolean isCarPlay()

    Returns true if CarPlay permission is requested.

    ###### Returns

    true if CarPlay is requested

  - ### isAnnouncement

    public boolean isAnnouncement()

    Returns true if announcement permission is requested.

    ###### Returns

    true if announcement is requested

  - ### isProvidesAppSettings

    public boolean isProvidesAppSettings()

    Returns true if the app advertises in-app notification settings.

    ###### Returns

    true if the app provides its own settings

  - ### toAuthorizationOptionsMask

    public int toAuthorizationOptionsMask()

    Converts this request into the bitmask consumed by the iOS native layer. The bit values match the iOS `UNAuthorizationOption` constants.

    ###### Returns

    the authorization options bitmask