Class NotificationPermissionRequest
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 -
Method Summary
Modifier and TypeMethodDescriptionalert(boolean b) Requests permission to display alerts.announcement(boolean b) Requests permission for Siri to read out notifications (iOS).badge(boolean b) Requests permission to update the app icon badge.carPlay(boolean b) Requests permission to display notifications in CarPlay (iOS).critical(boolean b) Requests permission to send critical alerts (iOS).booleanisAlert()Returns true if alert permission is requested.booleanReturns true if announcement permission is requested.booleanisBadge()Returns true if badge permission is requested.booleanReturns true if CarPlay permission is requested.booleanReturns true if critical alert permission is requested.booleanReturns true if the app advertises in-app notification settings.booleanReturns true if provisional authorization is requested.booleanisSound()Returns true if sound permission is requested.booleanReturns true if the time sensitive interruption level is requested.providesAppSettings(boolean b) Requests that the app provide its own in-app notification settings (iOS).provisional(boolean b) Requests provisional authorization (iOS).sound(boolean b) Requests permission to play notification sounds.timeSensitive(boolean b) Requests the ability to mark notifications as time sensitive (iOS).intConverts this request into the bitmask consumed by the iOS native layer.
-
Constructor Details
-
NotificationPermissionRequest
public NotificationPermissionRequest()
-
-
Method Details
-
alert
Requests permission to display alerts. Enabled by default.
Parameters
b: true to request alert permission
Returns
this request for chaining
-
sound
Requests permission to play notification sounds. Enabled by default.
Parameters
b: true to request sound permission
Returns
this request for chaining
-
badge
Requests permission to update the app icon badge. Enabled by default.
Parameters
b: true to request badge permission
Returns
this request for chaining
-
provisional
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
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
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
Requests permission to display notifications in CarPlay (iOS). Ignored elsewhere.
Parameters
b: true to request CarPlay permission
Returns
this request for chaining
-
announcement
Requests permission for Siri to read out notifications (iOS). Ignored elsewhere.
Parameters
b: true to request announcement permission
Returns
this request for chaining
-
providesAppSettings
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
UNAuthorizationOptionconstants.Returns
the authorization options bitmask
-