NotificationRequest

描述通知的请求。

说明:

本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

NotificationRequest

系统能力:以下各项对应的系统能力均为SystemCapability.Notification.Notification

名称 类型 只读 必填 说明
content NotificationContent 通知内容。
id number 通知ID。
slotType(deprecated) SlotType 通道类型。
从API version 11开始不再维护,建议使用notificationSlotType代替。
notificationSlotType11+ SlotType 通道类型。
isOngoing boolean 是否进行时通知。
isUnremovable boolean 预留能力,暂不支持。
deliveryTime number 通知发送时间。
tapDismissed boolean 通知是否自动清除。
autoDeletedTime number 自动清除的时间。
wantAgent WantAgent WantAgent封装了应用的行为意图,点击通知时触发该行为。
extraInfo {[key: string]: any} 扩展参数。
color number 通知背景颜色。预留能力,暂未支持。
colorEnabled boolean 通知背景颜色是否使能。预留能力,暂未支持。
isAlertOnce boolean 设置是否仅有一次此通知提醒。
isStopwatch boolean 是否显示已用时间。
isCountDown boolean 是否显示倒计时时间。
isFloatingIcon boolean 是否显示状态栏图标。
label string 通知标签。
badgeIconStyle number 通知角标类型。预留能力,暂未支持。
showDeliveryTime boolean 是否显示分发时间。
actionButtons Array<NotificationActionButton> 通知按钮,最多三个按钮。
smallIcon image.PixelMap 通知小图标。可选字段,图像像素的总字节数不超过100KB。实际显示效果依赖于设备能力和通知中心UI样式。
largeIcon image.PixelMap 通知大图标。可选字段,图像像素的总字节数不超过100KB。实际显示效果依赖于设备能力和通知中心UI样式。
creatorBundleName string 创建通知的包名。
creatorUid number 创建通知的UID。
creatorPid number 创建通知的PID。
creatorUserId8+ number 创建通知的UserId。
hashCode string 通知唯一标识。
groupName8+ string 组通知名称。
template8+ NotificationTemplate 通知模板。
distributedOption8+ DistributedOptions 分布式通知的选项。
notificationFlags8+ NotificationFlags 获取NotificationFlags。
removalWantAgent9+ WantAgent 当移除通知时,通知将被重定向到的WantAgent实例。当前不支持跳转UIAbility,只支持发布公共事件及跳转系统Service能力(WantAgent的OperationType >= 3)。
badgeNumber9+ number 应用程序图标上显示的通知数。

DistributedOptions

描述分布式选项。

系统能力:以下各项对应的系统能力均为SystemCapability.Notification.Notification

名称 类型 必填 说明
isDistributed8+ boolean 是否为分布式通知。
supportDisplayDevices8+ Array<string> 可以同步通知到的设备列表。
supportOperateDevices8+ Array<string> 可以打开通知的设备列表。