通知管理的能力

2024-01-23 13:00 更新

本模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知通道,订阅、取消订阅通知,获取通知的使能状态、角标使能状态,获取通知的相关信息等。

说明

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

通知订阅和取消订阅仅对系统应用开放。

导入模块

  1. import Notification from '@ohos.notification';

Notification.publish

publish(request: NotificationRequest, callback: AsyncCallback<void>): void

发布通知(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

request

NotificationRequest

是

用于设置要发布通知的内容和相关配置信息。

callback

AsyncCallback<void>

是

发布通知的回调方法。

示例:

  1. // publish回调
  2. function publishCallback(err) {
  3. if (err.code) {
  4. console.info("publish failed " + JSON.stringify(err));
  5. } else {
  6. console.info("publish success");
  7. }
  8. }
  9. // 通知Request对象
  10. let notificationRequest = {
  11. id: 1,
  12. content: {
  13. contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
  14. normal: {
  15. title: "test_title",
  16. text: "test_text",
  17. additionalText: "test_additionalText"
  18. }
  19. }
  20. };
  21. Notification.publish(notificationRequest, publishCallback);

Notification.publish

publish(request: NotificationRequest): Promise<void>

发布通知(Promise形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

request

NotificationRequest

是

用于设置要发布通知的内容和相关配置信息。

示例:

  1. // 通知Request对象
  2. let notificationRequest = {
  3. notificationId: 1,
  4. content: {
  5. contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
  6. normal: {
  7. title: "test_title",
  8. text: "test_text",
  9. additionalText: "test_additionalText"
  10. }
  11. }
  12. };
  13. Notification.publish(notificationRequest).then(() => {
  14. console.info("publish success");
  15. });

Notification.cancel

cancel(id: number, label: string, callback: AsyncCallback<void>): void

通过通知ID和通知标签取消已发布的通知(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

id

number

是

通知ID。

label

string

是

通知标签。

callback

AsyncCallback<void>

是

表示被指定的回调方法。

示例:

  1. // cancel回调
  2. function cancelCallback(err) {
  3. if (err.code) {
  4. console.info("cancel failed " + JSON.stringify(err));
  5. } else {
  6. console.info("cancel success");
  7. }
  8. }
  9. Notification.cancel(0, "label", cancelCallback);

Notification.cancel

cancel(id: number, label?: string): Promise<void>

取消与指定通知ID相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

id

number

是

通知ID。

label

string

否

通知标签。

示例:

  1. Notification.cancel(0).then(() => {
  2. console.info("cancel success");
  3. });

Notification.cancel

cancel(id: number, callback: AsyncCallback<void>): void

取消与指定通知ID相匹配的已发布通知(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

id

number

是

通知ID。

callback

AsyncCallback<void>

是

表示被指定的回调方法。

示例:

  1. // cancel回调
  2. function cancelCallback(err) {
  3. if (err.code) {
  4. console.info("cancel failed " + JSON.stringify(err));
  5. } else {
  6. console.info("cancel success");
  7. }
  8. }
  9. Notification.cancel(0, cancelCallback);

Notification.cancelAll

cancelAll(callback: AsyncCallback<void>): void

取消所有已发布的通知(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

callback

AsyncCallback<void>

是

表示被指定的回调方法。

示例:

  1. // cancel回调
  2. function cancelAllCallback(err) {
  3. if (err.code) {
  4. console.info("cancelAll failed " + JSON.stringify(err));
  5. } else {
  6. console.info("cancelAll success");
  7. }
  8. }
  9. Notification.cancelAll(cancelAllCallback);

Notification.cancelAll

cancelAll(): Promise<void>

取消所有已发布的通知(Promise形式)。

系统能力:SystemCapability.Notification.Notification

示例:

  1. Notification.cancelAll().then(() => {
  2. console.info("cancelAll success");
  3. });

Notification.addSlot

addSlot(type: SlotType, callback: AsyncCallback<void>): void

创建指定类型的通知通道(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

type

SlotType

是

要创建的通知通道的类型。

callback

AsyncCallback<void>

是

表示被指定的回调方法。

示例:

  1. // addslot回调
  2. function addSlotCallBack(err) {
  3. if (err.code) {
  4. console.info("addSlot failed " + JSON.stringify(err));
  5. } else {
  6. console.info("addSlot success");
  7. }
  8. }
  9. Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);

Notification.addSlot

addSlot(type: SlotType): Promise<void>

创建指定类型的通知通道(Promise形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

type

SlotType

是

要创建的通知通道的类型。

示例:

  1. Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
  2. console.info("addSlot success");
  3. });

Notification.getSlot

getSlot(slotType: SlotType, callback: AsyncCallback<NotificationSlot>): void

获取一个指定类型的通知通道(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

slotType

SlotType

是

通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。

callback

AsyncCallback<NotificationSlot>

是

表示被指定的回调方法。

示例:

  1. // getSlot回调
  2. function getSlotCallback(err, data) {
  3. if (err.code) {
  4. console.info("getSlot failed " + JSON.stringify(err));
  5. } else {
  6. console.info("getSlot success");
  7. }
  8. }
  9. let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
  10. Notification.getSlot(slotType, getSlotCallback);

Notification.getSlot

getSlot(slotType: SlotType): Promise<NotificationSlot>

获取一个指定类型的通知通道(Promise形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

slotType

SlotType

是

通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。

返回值:

类型

说明

Promise<NotificationSlot>

以Promise形式返回获取一个通知通道。

示例:

  1. let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
  2. Notification.getSlot(slotType).then((data) => {
  3. console.info("getSlot success, data: " + JSON.stringify(data));
  4. });

Notification.getSlots

getSlots(callback: AsyncCallback<Array<NotificationSlot>>): void

获取此应用程序的所有通知通道(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

callback

AsyncCallback<Array<NotificationSlot>>

是

以callback形式返回获取此应用程序的所有通知通道的结果。

示例:

  1. // getSlots回调
  2. function getSlotsCallback(err, data) {
  3. if (err.code) {
  4. console.info("getSlots failed " + JSON.stringify(err));
  5. } else {
  6. console.info("getSlots success");
  7. }
  8. }
  9. Notification.getSlots(getSlotsCallback);

Notification.getSlots

getSlots(): Promise<Array<NotificationSlot>>

获取此应用程序的所有通知通道(Promise形式)。

系统能力:SystemCapability.Notification.Notification

返回值:

类型

说明

Promise<Array<NotificationSlot>>

以Promise形式返回获取此应用程序的所有通知通道的结果。

示例:

  1. Notification.getSlots().then((data) => {
  2. console.info("getSlots success, data: " + JSON.stringify(data));
  3. });

Notification.removeSlot

removeSlot(slotType: SlotType, callback: AsyncCallback<void>): void

删除指定类型的通知通道(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

slotType

SlotType

是

通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。

callback

AsyncCallback<void>

是

表示被指定的回调方法。

示例:

  1. // removeSlot回调
  2. function removeSlotCallback(err) {
  3. if (err.code) {
  4. console.info("removeSlot failed " + JSON.stringify(err));
  5. } else {
  6. console.info("removeSlot success");
  7. }
  8. }
  9. let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
  10. Notification.removeSlot(slotType,removeSlotCallback);

Notification.removeSlot

removeSlot(slotType: SlotType): Promise<void>

删除指定类型的通知通道(Promise形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

slotType

SlotType

是

通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。

示例:

  1. let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
  2. Notification.removeSlot(slotType).then(() => {
  3. console.info("removeSlot success");
  4. });

Notification.removeAllSlots

removeAllSlots(callback: AsyncCallback<void>): void

删除所有通知通道(callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

callback

AsyncCallback<void>

是

表示被指定的回调方法。

示例:

  1. function removeAllCallBack(err) {
  2. if (err.code) {
  3. console.info("removeAllSlots failed " + JSON.stringify(err));
  4. } else {
  5. console.info("removeAllSlots success");
  6. }
  7. }
  8. Notification.removeAllSlots(removeAllCallBack);

Notification.removeAllSlots

removeAllSlots(): Promise<void>

删除所有通知通道(Promise形式)。

系统能力:SystemCapability.Notification.Notification

示例:

  1. Notification.removeAllSlots().then(() => {
  2. console.info("removeAllSlots success");
  3. });

Notification.getActiveNotificationCount

getActiveNotificationCount(callback: AsyncCallback<number>): void

获取当前应用未删除的通知数(Callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

callback

AsyncCallback<number>

是

获取未删除通知数回调函数。

示例:

  1. function getActiveNotificationCountCallback(err, data) {
  2. if (err.code) {
  3. console.info("getActiveNotificationCount failed " + JSON.stringify(err));
  4. } else {
  5. console.info("getActiveNotificationCount success");
  6. }
  7. }
  8. Notification.getActiveNotificationCount(getActiveNotificationCountCallback);

Notification.getActiveNotificationCount

getActiveNotificationCount(): Promise<number>

获取当前应用未删除的通知数(Promise形式)。

系统能力:SystemCapability.Notification.Notification

返回值:

类型

说明

Promise<number>

以Promise形式返回获取当前应用未删除通知数。

示例:

  1. Notification.getActiveNotificationCount().then((data) => {
  2. console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
  3. });

Notification.getActiveNotifications

getActiveNotifications(callback: AsyncCallback<Array<NotificationRequest>>): void

获取当前应用未删除的通知列表(Callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

callback

AsyncCallback<Array<NotificationRequest>>

是

获取当前应用通知列表回调函数。

示例:

  1. function getActiveNotificationsCallback(err, data) {
  2. if (err.code) {
  3. console.info("getActiveNotifications failed " + JSON.stringify(err));
  4. } else {
  5. console.info("getActiveNotifications success");
  6. }
  7. }
  8. Notification.getActiveNotifications(getActiveNotificationsCallback);

Notification.getActiveNotifications

getActiveNotifications(): Promise<Array<NotificationRequest>>

获取当前应用未删除的通知列表(Promise形式)。

系统能力:SystemCapability.Notification.Notification

返回值:

类型

说明

Promise<Array<NotificationRequest>>

以Promise形式返回获取当前应用通知列表。

示例:

  1. Notification.getActiveNotifications().then((data) => {
  2. console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
  3. });

Notification.cancelGroup8+

cancelGroup(groupName: string, callback: AsyncCallback<void>): void

取消本应用指定组下的通知(Callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

groupName

string

是

通知组名称,此名称需要在发布通知时通过NotificationRequest对象指定。

callback

AsyncCallback<void>

是

取消本应用指定组下通知的回调函数。

示例:

  1. function cancelGroupCallback(err) {
  2. if (err.code) {
  3. console.info("cancelGroup failed " + JSON.stringify(err));
  4. } else {
  5. console.info("cancelGroup success");
  6. }
  7. }
  8. let groupName = "GroupName";
  9. Notification.cancelGroup(groupName, cancelGroupCallback);

Notification.cancelGroup8+

cancelGroup(groupName: string): Promise<void>

取消本应用指定组下的通知(Promise形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

groupName

string

是

通知组名称。

示例:

  1. let groupName = "GroupName";
  2. Notification.cancelGroup(groupName).then(() => {
  3. console.info("cancelGroup success");
  4. });

Notification.isSupportTemplate8+

isSupportTemplate(templateName: string, callback: AsyncCallback<boolean>): void

查询模板是否存在(Callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

templateName

string

是

模板名称。

callback

AsyncCallback<boolean>

是

查询模板是否存在的回调函数。

示例:

  1. let templateName = 'process';
  2. function isSupportTemplateCallback(err, data) {
  3. if (err.code) {
  4. console.info("isSupportTemplate failed " + JSON.stringify(err));
  5. } else {
  6. console.info("isSupportTemplate success");
  7. }
  8. }
  9. Notification.isSupportTemplate(templateName, isSupportTemplateCallback);

Notification.isSupportTemplate8+

isSupportTemplate(templateName: string): Promise<boolean>

查询模板是否存在(Promise形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

templateName

string

是

模板名称。

返回值:

类型

说明

Promise<boolean>

Promise方式返回模板是否存在的结果。

示例:

  1. let templateName = 'process';
  2. Notification.isSupportTemplate(templateName).then((data) => {
  3. console.info("isSupportTemplate success, data: " + JSON.stringify(data));
  4. });

Notification.requestEnableNotification8+

requestEnableNotification(callback: AsyncCallback<void>): void

应用请求通知使能(Callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

callback

AsyncCallback<void>

是

应用请求通知使能的回调函数。

示例:

  1. function requestEnableNotificationCallback(err) {
  2. if (err.code) {
  3. console.info("requestEnableNotification failed " + JSON.stringify(err));
  4. } else {
  5. console.info("requestEnableNotification success");
  6. }
  7. };
  8. Notification.requestEnableNotification(requestEnableNotificationCallback);

Notification.requestEnableNotification8+

requestEnableNotification(): Promise<void>

应用请求通知使能(Promise形式)。

系统能力:SystemCapability.Notification.Notification

示例:

  1. Notification.requestEnableNotification().then(() => {
  2. console.info("requestEnableNotification success");
  3. });

Notification.isDistributedEnabled8+

isDistributedEnabled(callback: AsyncCallback<boolean>): void

查询设备是否支持分布式通知(Callback形式)。

系统能力:SystemCapability.Notification.Notification

参数:

参数名

类型

必填

说明

callback

AsyncCallback<boolean>

是

设备是否支持分布式通知的回调函数。

示例:

  1. function isDistributedEnabledCallback(err, data) {
  2. if (err.code) {
  3. console.info("isDistributedEnabled failed " + JSON.stringify(err));
  4. } else {
  5. console.info("isDistributedEnabled success " + JSON.stringify(data));
  6. }
  7. };
  8. Notification.isDistributedEnabled(isDistributedEnabledCallback);

Notification.isDistributedEnabled8+

isDistributedEnabled(): Promise<boolean>

查询设备是否支持分布式通知(Promise形式)。

系统能力:SystemCapability.Notification.Notification

返回值:

类型

说明

Promise<boolean>

Promise方式返回设备是否支持分布式通知的结果。

示例:

  1. Notification.isDistributedEnabled().then((data) => {
  2. console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
  3. });

ContentType

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

名称

值

说明

NOTIFICATION_CONTENT_BASIC_TEXT

NOTIFICATION_CONTENT_BASIC_TEXT

普通类型通知。

NOTIFICATION_CONTENT_LONG_TEXT

NOTIFICATION_CONTENT_LONG_TEXT

长文本类型通知。

NOTIFICATION_CONTENT_PICTURE

NOTIFICATION_CONTENT_PICTURE

图片类型通知。

NOTIFICATION_CONTENT_CONVERSATION

NOTIFICATION_CONTENT_CONVERSATION

社交类型通知。

NOTIFICATION_CONTENT_MULTILINE

NOTIFICATION_CONTENT_MULTILINE

多行文本类型通知。

SlotLevel

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

名称

值

说明

LEVEL_NONE

0

表示关闭通知功能。

LEVEL_MIN

1

表示通知功能已启用,但状态栏中不显示通知图标,且没有横幅或提示音。

LEVEL_LOW

2

表示通知功能已启用,且状态栏中显示通知图标,但没有横幅或提示音。

LEVEL_DEFAULT

3

表示通知功能已启用,状态栏中显示通知图标,没有横幅但有提示音。

LEVEL_HIGH

4

表示通知功能已启用,状态栏中显示通知图标,有横幅和提示音。

BundleOption

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

名称

类型

可读

可写

说明

bundle

string

是

是

应用的包信息。

uid

number

是

是

用户ID。

NotificationKey

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

名称

类型

可读

可写

说明

id

number

是

是

通知ID。

label

string

是

是

通知标签。

SlotType

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

名称

值

说明

UNKNOWN_TYPE

0

未知类型。

SOCIAL_COMMUNICATION

1

社交类型。

SERVICE_INFORMATION

2

服务类型。

CONTENT_INFORMATION

3

内容类型。

OTHER_TYPES

0xFFFF

其他类型。

NotificationActionButton

描述通知中显示的操作按钮。

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

名称

类型

可读

可写

说明

title

string

是

是

按钮标题。

wantAgent

WantAgent

是

是

点击按钮时触发的WantAgent。

extras

{ [key: string]: any }

是

是

按钮扩展信息。

userInput8+

NotificationUserInput

是

是

用户输入对象实例。

NotificationBasicContent

描述普通文本通知。

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

名称

类型

可读

可写

说明

title

string

是

是

通知标题。

text

string

是

是

通知内容。

additionalText

string

是

是

通知附加内容,是对通知内容的补充。

NotificationLongTextContent

描述长文本通知。

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

名称

类型

可读

可写

说明

title

string

是

是

通知标题。

text

string

是

是

通知内容。

additionalText

string

是

是

通知附加内容,是对通知内容的补充。

longText

string

是

是

通知的长文本。

briefText

string

是

是

通知概要内容,是对通知内容的总结。

expandedTitle

string

是

是

通知展开时的标题。

NotificationMultiLineContent

描述多行文本通知。

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

名称

类型

可读

可写

说明

title

string

是

是

通知标题。

text

string

是

是

通知内容。

additionalText

string

是

是

通知附加内容,是对通知内容的补充。

briefText

string

是

是

通知概要内容,是对通知内容的总结。

longTitle

string

是

是

通知展开时的标题。

lines

Array<string>

是

是

通知的多行文本。

NotificationPictureContent

描述附有图片的通知。

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

名称

类型

可读

可写

说明

title

string

是

是

通知标题。

text

string

是

是

通知内容。

additionalText

string

是

是

通知附加内容,是对通知内容的补充。

briefText

string

是

是

通知概要内容,是对通知内容的总结。

expandedTitle

string

是

是

通知展开时的标题。

picture

image.PixelMap

是

是

通知的图片内容。

NotificationContent

描述通知类型。

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

名称

类型

可读

可写

说明

contentType

ContentType

是

是

通知内容类型。

normal

NotificationBasicContent

是

是

基本类型通知内容。

longText

NotificationLongTextContent

是

是

长文本类型通知内容。

multiLine

NotificationMultiLineContent

是

是

多行类型通知内容。

picture

NotificationPictureContent

是

是

图片类型通知内容。

NotificationFlags8+

描述通知标志的实例。

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

名称

类型

可读

可写

说明

soundEnabled

NotificationFlagStatus

是

否

是否启用声音提示。

vibrationEnabled

NotificationFlagStatus

是

否

是否启用振动提醒功能。

NotificationRequest

描述通知的请求。

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

名称

类型

可读

可写

说明

content

NotificationContent

是

是

通知内容。

id

number

是

是

通知ID。

slotType

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

是

是

通知小图标。可选字段,大小不超过30KB。

largeIcon

image.PixelMap

是

是

通知大图标。可选字段,大小不超过30KB。

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实例。

badgeNumber9+

number

是

是

应用程序图标上显示的通知数。

DistributedOptions8+

描述分布式选项。

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

名称

类型

可读

可写

说明

isDistributed

boolean

是

是

是否为分布式通知。

supportDisplayDevices

Array<string>

是

是

可以同步通知到的设备列表。

supportOperateDevices

Array<string>

是

是

可以打开通知的设备列表。

NotificationSlot

描述通知槽

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

名称

类型

可读

可写

说明

type

SlotType

是

是

通道类型。

level

number

是

是

通知级别,不设置则根据通知渠道类型有默认值。

desc

string

是

是

通知渠道描述信息。

badgeFlag

boolean

是

是

是否显示角标。

bypassDnd

boolean

是

是

置是否在系统中绕过免打扰模式。

lockscreenVisibility

number

是

是

在锁定屏幕上显示通知的模式。

vibrationEnabled

boolean

是

是

是否可振动。

sound

string

是

是

通知提示音。

lightEnabled

boolean

是

是

是否闪灯。

lightColor

number

是

是

通知灯颜色。

vibrationValues

Array<number>

是

是

通知振动样式。

enabled9+

boolean

是

否

此通知插槽中的启停状态。

NotificationTemplate8+

通知模板。

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

名称

类型

可读

可写

说明

name

string

是

是

模板名称。

data

{[key:string]: Object}

是

是

模板数据。

NotificationUserInput8+

保存用户输入的通知消息。

系统能力:SystemCapability.Notification.Notification

名称

类型

可读

可写

说明

inputKey

string

是

是

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号