NotificationRequest

The NotificationRequest module provides APIs for defining the notification request.

NOTE

The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.

NotificationRequest

System capability: SystemCapability.Notification.Notification

Name Type Read-only Mandatory Description
content NotificationContent No Yes Notification content.
id number No No Notification ID.
slotType SlotType No No Notification slot type.
isOngoing boolean No No Whether the notification is an ongoing notification.
isUnremovable boolean No No Whether the notification can be removed. This parameter applies to continuous notification tasks, such as navigation and music playback. If a notifiation is not removable, it will not be deleted when the user touches the delete button below the notification, but it can still be deleted by swiping left on the notification and touching the delete button.
deliveryTime number No No Time when the notification is sent.
tapDismissed boolean No No Whether the notification is automatically cleared.
autoDeletedTime number No No Time when the notification is automatically cleared.
wantAgent WantAgent No No WantAgent instance to which the notification will be redirected after being clicked.
extraInfo {[key: string]: any} No No Extended parameters.
color number No No Background color of the notification. Not supported currently.
colorEnabled boolean No No Whether the notification background color can be enabled. Not supported currently.
isAlertOnce boolean No No Whether the notification triggers an alert only once.
isStopwatch boolean No No Whether to display the stopwatch.
isCountDown boolean No No Whether to display the countdown time.
isFloatingIcon boolean No No Whether the notification is displayed as a floating icon in the status bar.
label string No No Notification label.
badgeIconStyle number No No Notification badge type. Not supported currently.
showDeliveryTime boolean No No Whether to display the time when the notification is delivered.
actionButtons Array<NotificationActionButton> No No Buttons in the notification. Up to three buttons are allowed.
smallIcon image.PixelMap No No Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.
largeIcon image.PixelMap No No Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.
creatorBundleName string Yes No Name of the bundle that creates the notification.
creatorUid number Yes No UID used for creating the notification.
creatorPid number Yes No PID used for creating the notification.
creatorUserId8+ number Yes No ID of the user who creates the notification.
hashCode string Yes No Unique ID of the notification.
classification string No No Notification category.
System API: This is a system API.
groupName8+ string No No Notification group name.
template8+ NotificationTemplate No No Notification template.
isRemoveAllowed8+ boolean No No Whether the notification can be removed. If a notifiation is not removable, it will not be deleted when the user touches the delete button below the notification, but it can still be deleted by swiping left on the notification and touching the delete button.
System API: This is a system API.
Required permissions: ohos.permission.SET_UNREMOVABLE_NOTIFICATION
source8+ number Yes No Notification source.
System API: This is a system API.
distributedOption8+ DistributedOptions No No Distributed notification options.
deviceId8+ string Yes No Device ID of the notification source.
System API: This is a system API.
notificationFlags8+ NotificationFlags Yes No Notification flags.
removalWantAgent9+ WantAgent No No WantAgent instance to which the notification will be redirected when it is removed.
badgeNumber9+ number No No Number of notifications displayed on the application icon.

DistributedOptions

Describes distributed notification options.

System capability: SystemCapability.Notification.Notification

Name Type Mandatory Description
isDistributed8+ boolean No Whether the notification is a distributed notification.
supportDisplayDevices8+ Array<string> No List of the devices to which the notification can be synchronized.
supportOperateDevices8+ Array<string> No List of the devices on which the notification can be opened.
remindType8+ number No Notification reminder type.
System API: This is a system API.