diff --git a/api/@ohos.notificationManager.d.ts b/api/@ohos.notificationManager.d.ts index e13933c423..837761ab32 100644 --- a/api/@ohos.notificationManager.d.ts +++ b/api/@ohos.notificationManager.d.ts @@ -30,6 +30,8 @@ import { NotificationFlags as _NotificationFlags } from './notification/notifica import { NotificationFlagStatus as _NotificationFlagStatus } from './notification/notificationFlags'; import { NotificationRequest as _NotificationRequest } from './notification/notificationRequest'; import { DistributedOptions as _DistributedOptions } from './notification/notificationRequest'; +import { NotificationFilter as _NotificationFilter } from './notification/notificationRequest'; +import { NotificationCheckRequest as _NotificationCheckRequest } from './notification/notificationRequest'; import { NotificationSlot as _NotificationSlot } from './notification/notificationSlot'; import { NotificationSorting as _NotificationSorting } from './notification/notificationSorting'; import { NotificationTemplate as _NotificationTemplate } from './notification/notificationTemplate'; @@ -64,8 +66,13 @@ declare namespace notificationManager { * @throws { BusinessError } 1600003 - Failed to connect service. * @throws { BusinessError } 1600004 - Notification is not enabled. * @throws { BusinessError } 1600005 - Notification slot is not enabled. + * @throws { BusinessError } 1600007 - The notification is not exist. * @throws { BusinessError } 1600009 - Over max number notifications per second. * @throws { BusinessError } 1600012 - No memory space. + * @throws { BusinessError } 1600014 - No relevent right. + * @throws { BusinessError } 1600015 - The current notification status does not support duplicate configurations. + * @throws { BusinessError } 1600016 - The notification version for this update is too low. + * @throws { BusinessError } 2300007 - Network is unreachable. * @syscap SystemCapability.Notification.Notification * @since 9 */ @@ -84,8 +91,13 @@ declare namespace notificationManager { * @throws { BusinessError } 1600003 - Failed to connect service. * @throws { BusinessError } 1600004 - Notification is not enabled. * @throws { BusinessError } 1600005 - Notification slot is not enabled. + * @throws { BusinessError } 1600007 - The notification is not exist. * @throws { BusinessError } 1600009 - Over max number notifications per second. * @throws { BusinessError } 1600012 - No memory space. + * @throws { BusinessError } 1600014 - No relevent right. + * @throws { BusinessError } 1600015 - The current notification status does not support duplicate configurations. + * @throws { BusinessError } 1600016 - The notification version for this update is too low. + * @throws { BusinessError } 2300007 - Network is unreachable. * @syscap SystemCapability.Notification.Notification * @since 9 */ @@ -106,9 +118,14 @@ declare namespace notificationManager { * @throws { BusinessError } 1600003 - Failed to connect service. * @throws { BusinessError } 1600004 - Notification is not enabled. * @throws { BusinessError } 1600005 - Notification slot is not enabled. + * @throws { BusinessError } 1600007 - The notification is not exist. * @throws { BusinessError } 1600008 - The user is not exist. * @throws { BusinessError } 1600009 - Over max number notifications per second. * @throws { BusinessError } 1600012 - No memory space. + * @throws { BusinessError } 1600014 - No relevent right. + * @throws { BusinessError } 1600015 - The current notification status does not support duplicate configurations. + * @throws { BusinessError } 1600016 - The notification version for this update is too low. + * @throws { BusinessError } 2300007 - Network is unreachable. * @syscap SystemCapability.Notification.Notification * @systemapi * @since 9 @@ -130,9 +147,14 @@ declare namespace notificationManager { * @throws { BusinessError } 1600003 - Failed to connect service. * @throws { BusinessError } 1600004 - Notification is not enabled. * @throws { BusinessError } 1600005 - Notification slot is not enabled. + * @throws { BusinessError } 1600007 - The notification is not exist. * @throws { BusinessError } 1600008 - The user is not exist. * @throws { BusinessError } 1600009 - Over max number notifications per second. * @throws { BusinessError } 1600012 - No memory space. + * @throws { BusinessError } 1600014 - No relevent right. + * @throws { BusinessError } 1600015 - The current notification status does not support duplicate configurations. + * @throws { BusinessError } 1600016 - The notification version for this update is too low. + * @throws { BusinessError } 2300007 - Network is unreachable. * @syscap SystemCapability.Notification.Notification * @systemapi * @since 9 @@ -624,6 +646,19 @@ declare namespace notificationManager { * @systemapi * @since 9 */ + /** + * Checks whether this application allows to publish notifications. + * + * @param { AsyncCallback } callback - The callback of isNotificationEnabled. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 1600001 - Internal error. + * @throws { BusinessError } 1600002 - Marshalling or unmarshalling error. + * @throws { BusinessError } 1600003 - Failed to connect service. + * @throws { BusinessError } 1600008 - The user is not exist. + * @throws { BusinessError } 17700001 - The specified bundle name was not found. + * @syscap SystemCapability.Notification.Notification + * @since 11 + */ function isNotificationEnabled(callback: AsyncCallback): void; /** @@ -641,6 +676,19 @@ declare namespace notificationManager { * @systemapi * @since 9 */ + /** + * Checks whether this application allows to publish notifications. + * + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 1600001 - Internal error. + * @throws { BusinessError } 1600002 - Marshalling or unmarshalling error. + * @throws { BusinessError } 1600003 - Failed to connect service. + * @throws { BusinessError } 1600008 - The user is not exist. + * @throws { BusinessError } 17700001 - The specified bundle name was not found. + * @syscap SystemCapability.Notification.Notification + * @since 11 + */ function isNotificationEnabled(): Promise; /** @@ -963,6 +1011,38 @@ declare namespace notificationManager { */ function getActiveNotifications(): Promise>; + /** + * Get the live view notification by bundle option and notification key. If the extraInfoKeys is provided, + * filter the additional information of the live view notification and return the filtered result. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER + * @param { NotificationFilter } filter - The bundle, notification key and additional information filter of the live view notification. + * @param { AsyncCallback } callback - The callback of getActiveNotificationByFilter. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 1600007 - The notification is not exist. + * @throws { BusinessError } 17700001 - The specified bundle name was not found. + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + function getActiveNotificationByFilter(filter: NotificationFilter, callback: AsyncCallback): void; + + /** + * Get the live view notification by bundle option and notification key. If the extraInfoKeys is provided, + * filter the additional information of the live view notification and return the filtered result. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER + * @param { NotificationFilter } filter - The bundle, notification key and additional information filter of the live view notification. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 1600007 - The notification is not exist. + * @throws { BusinessError } 17700001 - The specified bundle name was not found. + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + function getActiveNotificationByFilter(filter: NotificationFilter): Promise; + /** * Cancel the notification of a specified group for this application. * @@ -1560,6 +1640,7 @@ declare namespace notificationManager { * @throws { BusinessError } 1600001 - Internal error. * @throws { BusinessError } 1600002 - Marshalling or unmarshalling error. * @throws { BusinessError } 1600003 - Failed to connect service. + * @throws { BusinessError } 1600012 - No memory space. * @throws { BusinessError } 17700001 - The specified bundle name was not found. * @syscap SystemCapability.Notification.Notification * @systemapi @@ -1572,6 +1653,35 @@ declare namespace notificationManager { callback: AsyncCallback ): void; + /** + * Set whether the application slot is enabled. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER + * @param { BundleOption } bundle - The bundle option. + * @param { SlotType } type - Type of the notification slot. + * @param { boolean } enable - Set enable or not. + * @param { AsyncCallback } callback - The callback of setNotificationEnableSlot. + * @param { boolean } isForceControl - Is the slot enable affected by the main enable, false means affected. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application to call the interface. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 1600001 - Internal error. + * @throws { BusinessError } 1600002 - Marshalling or unmarshalling error. + * @throws { BusinessError } 1600003 - Failed to connect service. + * @throws { BusinessError } 1600012 - No memory space. + * @throws { BusinessError } 17700001 - The specified bundle name was not found. + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + function setNotificationEnableSlot( + bundle: BundleOption, + type: SlotType, + enable: boolean, + isForceControl: boolean, + callback: AsyncCallback, + ): void; + /** * Set whether the application slot is enabled. * @@ -1591,7 +1701,28 @@ declare namespace notificationManager { * @systemapi * @since 9 */ - function setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise; + /** + * Set whether the application slot is enabled. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER + * @param { BundleOption } bundle - The bundle option. + * @param { SlotType } type - Type of the notification slot. + * @param { boolean } enable - Set enable or not. + * @param { boolean } isForceControl - Is the slot enable affected by the main enable, false means affected. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application to call the interface. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 1600001 - Internal error. + * @throws { BusinessError } 1600002 - Marshalling or unmarshalling error. + * @throws { BusinessError } 1600003 - Failed to connect service. + * @throws { BusinessError } 1600012 - No memory space. + * @throws { BusinessError } 17700001 - The specified bundle name was not found. + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + function setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, isForceControl?: boolean): Promise; /** * Obtains whether the application slot is enabled. @@ -1756,6 +1887,26 @@ declare namespace notificationManager { */ function on(type: 'checkNotification', callback: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void; + /** + * Subscribe the callback for check notifications. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER + * @param { 'checkNotification' } type - Type of the callback to listen for. + * @param { NotificationCheckRequest } checkRequest - Check Request for filter notification request. + * @param { function } callback - callback - The callback of check notifications. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Not system application. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 1600001 - Internal error. + * @throws { BusinessError } 1600002 - Marshalling or unmarshalling error. + * @throws { BusinessError } 1600003 - Failed to connect service. + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + function on(type: 'checkNotification', checkRequest: NotificationCheckRequest, + callback: (checkInfo: NotificationCheckInfo) => Promise): void; + /** * Unsubscribe the callback for check notifications. * @@ -1887,6 +2038,17 @@ declare namespace notificationManager { */ notificationId: number; + /** + * Label of the notification. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER + * @type { string } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + label?: string; + /** * The notification content type. * @@ -1897,6 +2059,39 @@ declare namespace notificationManager { * @since 10 */ contentType: ContentType; + + /** + * UserId of the notification creator. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER + * @type { number } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + creatorUserId: number; + + /** + * Type of the notification slot. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER + * @type { SlotType } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + slotType: SlotType; + + /** + * Additional information of the live view notification. + * + * @permission ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER + * @type { [key: string]: any } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + extraInfos?: { [key: string]: any }; } /** @@ -2052,6 +2247,14 @@ declare namespace notificationManager { * @since 11 */ NOTIFICATION_CONTENT_SYSTEM_LIVE_VIEW, + + /** + * Common live view notification. + * + * @syscap SystemCapability.Notification.Notification + * @since 11 + */ + NOTIFICATION_CONTENT_LIVE_VIEW, } /** @@ -2366,6 +2569,22 @@ declare namespace notificationManager { */ export type NotificationRequest = _NotificationRequest; + /** + * Defines a NotificationFilter instance. + * + * @syscap SystemCapability.Notification.Notification + * @since 11 + */ + export type NotificationFilter = _NotificationFilter; + + /** + * Defines a NotificationCheckRequest instance. + * + * @syscap SystemCapability.Notification.Notification + * @since 11 + */ + export type NotificationCheckRequest = _NotificationCheckRequest; + /** * Describes distributed options. * diff --git a/api/notification/notificationContent.d.ts b/api/notification/notificationContent.d.ts index 33654aff75..1134716ca8 100644 --- a/api/notification/notificationContent.d.ts +++ b/api/notification/notificationContent.d.ts @@ -89,6 +89,101 @@ export interface NotificationLongTextContent extends NotificationBasicContent { expandedTitle: string; } +/** + * Enum for live view notification option type. + * + * @enum { number } + * @syscap SystemCapability.Security.AccessToken + * @systemapi + * @since 11 + */ +export enum LiveViewStatus { + /** + * Create the live view notification. + * + * @syscap SystemCapability.Security.AccessToken + * @systemapi + * @since 11 + */ + LIVE_VIEW_CREATE = 0, + /** + * Batch update the live view notification. + * + * @syscap SystemCapability.Security.AccessToken + * @systemapi + * @since 11 + */ + LIVE_VIEW_INCREMENTAL_UPDATE = 1, + /** + * Complete the live view notification. + * + * @syscap SystemCapability.Security.AccessToken + * @systemapi + * @since 11 + */ + LIVE_VIEW_END = 2, + /** + * Full update the live view notification. + * + * @syscap SystemCapability.Security.AccessToken + * @systemapi + * @since 11 + */ + LIVE_VIEW_FULL_UPDATE = 3 +} + +/** + * Describes a live view notification. + * + * @typedef NotificationLiveViewContent + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ +export interface NotificationLiveViewContent extends NotificationBasicContent { + /** + * Status of the live view (0: create, 1: batch update, 2: end, 3: full update). + * + * @type { LiveViewStatus } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + status: LiveViewStatus; + + /** + * Version of the live view with the same id. (If the version number stored in the database is less + * than 0, the version number is not verified at the current operation of update or end. Otherwise, the + * version number must be greater than the version number stored in the database.) + * + * @type { number } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + version: number; + + /** + * Additional information of the live view notification. + * + * @type { [key: string]: any} + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + extraInfo?: {[key: string]: any}; + + /** + * Picture information of the live view notification. + * + * @type { [key: string]: Array } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + pictureMap?: {[key: string]: Array}; +} + /** * Describes a multi-line text notification. * @@ -296,7 +391,7 @@ export interface NotificationTime { initialTime?: number; /** - * + * * Count down the time. * * @type { ?boolean } diff --git a/api/notification/notificationRequest.d.ts b/api/notification/notificationRequest.d.ts index c9fc76a02d..c853e8ba6b 100644 --- a/api/notification/notificationRequest.d.ts +++ b/api/notification/notificationRequest.d.ts @@ -16,11 +16,13 @@ import notification from '../@ohos.notification'; import image from '../@ohos.multimedia.image'; import type notificationManager from '../@ohos.notificationManager'; +import type notificationSubscribe from '../@ohos.notificationSubscribe'; import { WantAgent } from '../@ohos.wantAgent'; import { NotificationContent } from './notificationContent'; import { NotificationActionButton } from './notificationActionButton'; import { NotificationTemplate } from './notificationTemplate'; import { NotificationFlags } from './notificationFlags'; +import { BundleOption as _BundleOption } from './NotificationCommonDef'; /** * Defines a NotificationRequest instance. @@ -239,6 +241,16 @@ export interface NotificationRequest { */ largeIcon?: image.PixelMap; + /** + * Overlay notification icon. + * + * @type { ?image.PixelMap } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + overlayIcon?: image.PixelMap; + /** * The group information for this notification. * @@ -431,3 +443,83 @@ export interface DistributedOptions { */ readonly remindType?: number; } + +/** + * Describes notification filter. + * + * @typedef NotificationFilter + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ +export interface NotificationFilter { + /** + * BundleOption of the notification. + * + * @type { BundleOption } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + bundle: BundleOption; + + /** + * Indicates the label and id of the notification. + * + * @type { NotificationKey } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + notificationKey: notificationSubscribe.NotificationKey; + + /** + * Indicates the additional information filter keys list. + * + * @type { ?Array } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + extraInfoKeys?: Array; +} + +/** + * Describes notification check information. + * + * @typedef NotificationCheckRequest + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ +export interface NotificationCheckRequest { + /** + * The notification content type. + * + * @type { notificationManager.ContentType } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + contentType: notificationManager.ContentType; + + /** + * Type of the notification slot.. + * + * @type { notificationManager.SlotType } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + slotType: notificationManager.SlotType; + + /** + * Additional information of the notification. + * + * @type { Array } + * @syscap SystemCapability.Notification.Notification + * @systemapi + * @since 11 + */ + extraKeys: Array; +}