提交 f8bda595 编写于 作者: E ester.zhou

Update docs (15800)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 98c0f060
# NotificationActionButton
The **NotificationActionButton** module describes the button displayed in the notification.
> **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.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | Yes | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | Yes | Yes | User input object. |
# NotificationCommonDef
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## BundleOption
Provides the bundle information of an application.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Mandatory| Description |
| ------ | ------ |---- | ------ |
| bundle | string | Yes| Bundle information of the application.|
| uid | number | No| User ID.|
# NotificationContent
The **NotificationContent** module describes the notification content.
> **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.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | Yes | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. |
## NotificationBasicContent
Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
## NotificationLongTextContent
Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| longText | string | Yes | Yes | Long text of the notification. |
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent
Describes the multi-line text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| longTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. |
## NotificationPictureContent
Describes the picture-attached notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. |
# NotificationFlags
The **NotificationFlags** module implements a **NotificationFlags** instance.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. |
## NotificationFlagStatus
Describes the notification flag status.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------- | --- | --------------------------------- |
| TYPE_NONE | 0 | The default flag is used. |
| TYPE_OPEN | 1 | The notification flag is enabled. |
| TYPE_CLOSE | 2 | The notification flag is disabled. |
# NotificationRequest
The **NotificationRequest** module describes 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.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | Yes | Yes | Notification content. |
| id | number | Yes | Yes | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. |
| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. |
| deliveryTime | number | Yes | Yes | Time when the notification is sent. |
| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. |
| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked.|
| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. |
| color | number | Yes | Yes | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. |
| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. |
| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | Yes | Yes | Notification label. |
| badgeIconStyle | number | Yes | Yes | Notification badge type. |
| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. |
| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | Yes | Yes | Buttons in the notification. Up to three buttons are allowed. |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | 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<sup>8+<sup> | number | Yes | No | UID used for creating the notification. |
| creatorPid | number | Yes | No | PID used for creating the notification. |
| creatorUserId| number | Yes | No | ID of the user who creates the notification. |
| hashCode | string | Yes | No | Unique ID of the notification. |
| classification | string | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| groupName<sup>8+<sup> | string | Yes | Yes | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. |
| isRemoveAllowed<sup>8+<sup> | boolean | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| source<sup>8+<sup> | number | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | Yes | Yes | Distributed notification options. |
| deviceId<sup>8+<sup> | string | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | Yes | No | Notification flags. |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | number | Yes | Yes | Number of notifications displayed on the application icon. |
## DistributedOptions
Describes distributed notification options.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed<sup>8+<sup> | boolean | Yes | Yes | Whether the notification is a distributed notification. |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices to which the notification can be synchronized. |
| supportOperateDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices on which the notification can be opened. |
| remindType<sup>8+<sup> | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. |
# NotificationSlot
The **NotificationSlot** module describes the notification slot.
> **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.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.|
| desc | string | Yes | Yes | Notification slot description. |
| badgeFlag | boolean | Yes | Yes | Whether to display the badge. |
| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | Yes | Yes | Whether to enable vibration for the notification. |
| sound | string | Yes | Yes | Notification alert tone. |
| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. |
| lightColor | number | Yes | Yes | Indicator color of the notification. |
| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. |
| enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. |
# NotificationTemplate
The **NotificationTemplate** module describes the notification template.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.|
# NotificationUserInput
The **NotificationUserInput** module provides the notification user input.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.|
# @ohos.notification # @ohos.notification (Notification)
The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status. The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status.
...@@ -41,7 +41,7 @@ function publishCallback(err) { ...@@ -41,7 +41,7 @@ function publishCallback(err) {
} }
} }
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -51,8 +51,8 @@ var notificationRequest = { ...@@ -51,8 +51,8 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, publishCallback) Notification.publish(notificationRequest, publishCallback);
``` ```
...@@ -75,7 +75,7 @@ Publishes a notification. This API uses a promise to return the result. ...@@ -75,7 +75,7 @@ Publishes a notification. This API uses a promise to return the result.
```js ```js
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -85,7 +85,7 @@ var notificationRequest = { ...@@ -85,7 +85,7 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest).then(() => { Notification.publish(notificationRequest).then(() => {
console.info("publish success"); console.info("publish success");
}); });
...@@ -124,9 +124,9 @@ function publishCallback(err) { ...@@ -124,9 +124,9 @@ function publishCallback(err) {
} }
} }
// User ID // User ID
var userId = 1 let userId = 1;
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -136,7 +136,7 @@ var notificationRequest = { ...@@ -136,7 +136,7 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, userId, publishCallback); Notification.publish(notificationRequest, userId, publishCallback);
``` ```
...@@ -162,7 +162,7 @@ Publishes a notification to a specified user. This API uses a promise to return ...@@ -162,7 +162,7 @@ Publishes a notification to a specified user. This API uses a promise to return
**Example** **Example**
```js ```js
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -172,9 +172,9 @@ var notificationRequest = { ...@@ -172,9 +172,9 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
var userId = 1 let userId = 1;
Notification.publish(notificationRequest, userId).then(() => { Notification.publish(notificationRequest, userId).then(() => {
console.info("publish success"); console.info("publish success");
...@@ -209,7 +209,7 @@ function cancelCallback(err) { ...@@ -209,7 +209,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, "label", cancelCallback) Notification.cancel(0, "label", cancelCallback);
``` ```
...@@ -265,7 +265,7 @@ function cancelCallback(err) { ...@@ -265,7 +265,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, cancelCallback) Notification.cancel(0, cancelCallback);
``` ```
...@@ -295,11 +295,9 @@ function cancelAllCallback(err) { ...@@ -295,11 +295,9 @@ function cancelAllCallback(err) {
console.info("cancelAll success"); console.info("cancelAll success");
} }
} }
Notification.cancelAll(cancelAllCallback) Notification.cancelAll(cancelAllCallback);
``` ```
## Notification.cancelAll ## Notification.cancelAll
cancelAll(): Promise\<void\> cancelAll(): Promise\<void\>
...@@ -349,10 +347,10 @@ function addSlotCallBack(err) { ...@@ -349,10 +347,10 @@ function addSlotCallBack(err) {
} }
} }
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot, addSlotCallBack) Notification.addSlot(notificationSlot, addSlotCallBack);
``` ```
...@@ -379,9 +377,9 @@ Adds a notification slot. This API uses a promise to return the result. ...@@ -379,9 +377,9 @@ Adds a notification slot. This API uses a promise to return the result.
```js ```js
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot).then(() => { Notification.addSlot(notificationSlot).then(() => {
console.info("addSlot success"); console.info("addSlot success");
}); });
...@@ -415,7 +413,7 @@ function addSlotCallBack(err) { ...@@ -415,7 +413,7 @@ function addSlotCallBack(err) {
console.info("addSlot success"); console.info("addSlot success");
} }
} }
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
``` ```
...@@ -475,14 +473,14 @@ function addSlotsCallBack(err) { ...@@ -475,14 +473,14 @@ function addSlotsCallBack(err) {
} }
} }
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
// NotificationSlotArray object // NotificationSlotArray object
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray, addSlotsCallBack) Notification.addSlots(notificationSlotArray, addSlotsCallBack);
``` ```
...@@ -509,11 +507,11 @@ Adds an array of notification slots. This API uses a promise to return the resul ...@@ -509,11 +507,11 @@ Adds an array of notification slots. This API uses a promise to return the resul
```js ```js
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
// NotificationSlotArray object // NotificationSlotArray object
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray).then(() => { Notification.addSlots(notificationSlotArray).then(() => {
...@@ -549,8 +547,8 @@ function getSlotCallback(err, data) { ...@@ -549,8 +547,8 @@ function getSlotCallback(err, data) {
console.info("getSlot success"); console.info("getSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback) Notification.getSlot(slotType, getSlotCallback);
``` ```
...@@ -578,7 +576,7 @@ Obtains a notification slot of a specified type. This API uses a promise to retu ...@@ -578,7 +576,7 @@ Obtains a notification slot of a specified type. This API uses a promise to retu
**Example** **Example**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => { Notification.getSlot(slotType).then((data) => {
console.info("getSlot success, data: " + JSON.stringify(data)); console.info("getSlot success, data: " + JSON.stringify(data));
}); });
...@@ -611,7 +609,7 @@ function getSlotsCallback(err, data) { ...@@ -611,7 +609,7 @@ function getSlotsCallback(err, data) {
console.info("getSlots success"); console.info("getSlots success");
} }
} }
Notification.getSlots(getSlotsCallback) Notification.getSlots(getSlotsCallback);
``` ```
...@@ -666,8 +664,8 @@ function removeSlotCallback(err) { ...@@ -666,8 +664,8 @@ function removeSlotCallback(err) {
console.info("removeSlot success"); console.info("removeSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback) Notification.removeSlot(slotType,removeSlotCallback);
``` ```
...@@ -689,14 +687,12 @@ Removes a notification slot of a specified type. This API uses a promise to retu ...@@ -689,14 +687,12 @@ Removes a notification slot of a specified type. This API uses a promise to retu
**Example** **Example**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then(() => { Notification.removeSlot(slotType).then(() => {
console.info("removeSlot success"); console.info("removeSlot success");
}); });
``` ```
## Notification.removeAllSlots ## Notification.removeAllSlots
removeAllSlots(callback: AsyncCallback\<void\>): void removeAllSlots(callback: AsyncCallback\<void\>): void
...@@ -721,7 +717,7 @@ function removeAllCallBack(err) { ...@@ -721,7 +717,7 @@ function removeAllCallBack(err) {
console.info("removeAllSlots success"); console.info("removeAllSlots success");
} }
} }
Notification.removeAllSlots(removeAllCallBack) Notification.removeAllSlots(removeAllCallBack);
``` ```
...@@ -778,12 +774,12 @@ function subscribeCallback(err) { ...@@ -778,12 +774,12 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
var info = { let info = {
bundleNames: ["bundleName1", "bundleName2"] bundleNames: ["bundleName1", "bundleName2"]
} };
Notification.subscribe(subscriber, info, subscribeCallback); Notification.subscribe(subscriber, info, subscribeCallback);
``` ```
...@@ -821,9 +817,9 @@ function subscribeCallback(err) { ...@@ -821,9 +817,9 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -854,7 +850,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -854,7 +850,7 @@ Subscribes to a notification with the subscription information specified. This A
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
Notification.subscribe(subscriber).then(() => { Notification.subscribe(subscriber).then(() => {
...@@ -893,12 +889,12 @@ function unsubscribeCallback(err) { ...@@ -893,12 +889,12 @@ function unsubscribeCallback(err) {
console.info("unsubscribe success"); console.info("unsubscribe success");
} }
} }
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
var subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
} };
Notification.unsubscribe(subscriber, unsubscribeCallback); Notification.unsubscribe(subscriber, unsubscribeCallback);
``` ```
...@@ -925,10 +921,10 @@ Unsubscribes from a notification. This API uses a promise to return the result. ...@@ -925,10 +921,10 @@ Unsubscribes from a notification. This API uses a promise to return the result.
**Example** **Example**
```js ```js
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
var subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
Notification.unsubscribe(subscriber).then(() => { Notification.unsubscribe(subscriber).then(() => {
...@@ -936,8 +932,6 @@ Notification.unsubscribe(subscriber).then(() => { ...@@ -936,8 +932,6 @@ Notification.unsubscribe(subscriber).then(() => {
}); });
``` ```
## Notification.enableNotification ## Notification.enableNotification
enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
...@@ -968,9 +962,9 @@ function enableNotificationCallback(err) { ...@@ -968,9 +962,9 @@ function enableNotificationCallback(err) {
console.info("enableNotification success"); console.info("enableNotification success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.enableNotification(bundle, false, enableNotificationCallback); Notification.enableNotification(bundle, false, enableNotificationCallback);
``` ```
...@@ -998,9 +992,9 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -998,9 +992,9 @@ Sets whether to enable notification for a specified application. This API uses a
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.enableNotification(bundle, false).then(() => { Notification.enableNotification(bundle, false).then(() => {
console.info("enableNotification success"); console.info("enableNotification success");
}); });
...@@ -1037,9 +1031,9 @@ function isNotificationEnabledCallback(err, data) { ...@@ -1037,9 +1031,9 @@ function isNotificationEnabledCallback(err, data) {
console.info("isNotificationEnabled success"); console.info("isNotificationEnabled success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
``` ```
...@@ -1072,9 +1066,9 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1072,9 +1066,9 @@ Checks whether notification is enabled for a specified application. This API use
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle).then((data) => { Notification.isNotificationEnabled(bundle).then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
...@@ -1180,9 +1174,9 @@ function displayBadgeCallback(err) { ...@@ -1180,9 +1174,9 @@ function displayBadgeCallback(err) {
console.info("displayBadge success"); console.info("displayBadge success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false, displayBadgeCallback); Notification.displayBadge(bundle, false, displayBadgeCallback);
``` ```
...@@ -1210,16 +1204,14 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1210,16 +1204,14 @@ Sets whether to enable the notification badge for a specified application. This
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false).then(() => { Notification.displayBadge(bundle, false).then(() => {
console.info("displayBadge success"); console.info("displayBadge success");
}); });
``` ```
## Notification.isBadgeDisplayed ## Notification.isBadgeDisplayed
isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
...@@ -1249,9 +1241,9 @@ function isBadgeDisplayedCallback(err, data) { ...@@ -1249,9 +1241,9 @@ function isBadgeDisplayedCallback(err, data) {
console.info("isBadgeDisplayed success"); console.info("isBadgeDisplayed success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
``` ```
...@@ -1284,9 +1276,9 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1284,9 +1276,9 @@ Checks whether the notification badge is enabled for a specified application. Th
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle).then((data) => { Notification.isBadgeDisplayed(bundle).then((data) => {
console.info("isBadgeDisplayed success, data: " + JSON.stringify(data)); console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
}); });
...@@ -1324,12 +1316,12 @@ function setSlotByBundleCallback(err) { ...@@ -1324,12 +1316,12 @@ function setSlotByBundleCallback(err) {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
``` ```
...@@ -1357,12 +1349,12 @@ Sets the notification slot for a specified application. This API uses a promise ...@@ -1357,12 +1349,12 @@ Sets the notification slot for a specified application. This API uses a promise
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot).then(() => { Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
}); });
...@@ -1399,9 +1391,9 @@ function getSlotsByBundleCallback(err, data) { ...@@ -1399,9 +1391,9 @@ function getSlotsByBundleCallback(err, data) {
console.info("getSlotsByBundle success"); console.info("getSlotsByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
``` ```
...@@ -1434,9 +1426,9 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1434,9 +1426,9 @@ Obtains the notification slots of a specified application. This API uses a promi
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle).then((data) => { Notification.getSlotsByBundle(bundle).then((data) => {
console.info("getSlotsByBundle success, data: " + JSON.stringify(data)); console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
}); });
...@@ -1473,9 +1465,9 @@ function getSlotNumByBundleCallback(err, data) { ...@@ -1473,9 +1465,9 @@ function getSlotNumByBundleCallback(err, data) {
console.info("getSlotNumByBundle success"); console.info("getSlotNumByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
``` ```
...@@ -1508,9 +1500,9 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1508,9 +1500,9 @@ Obtains the number of notification slots of a specified application. This API us
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle).then((data) => { Notification.getSlotNumByBundle(bundle).then((data) => {
console.info("getSlotNumByBundle success, data: " + JSON.stringify(data)); console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
}); });
...@@ -1549,14 +1541,14 @@ function removeCallback(err) { ...@@ -1549,14 +1541,14 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason, removeCallback); Notification.remove(bundle, notificationKey, reason, removeCallback);
``` ```
...@@ -1585,14 +1577,14 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1585,14 +1577,14 @@ Removes a notification for a specified bundle. This API uses a promise to return
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason).then(() => { Notification.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
...@@ -1623,7 +1615,7 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1623,7 +1615,7 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**Example** **Example**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
function removeCallback(err) { function removeCallback(err) {
if (err.code) { if (err.code) {
...@@ -1632,7 +1624,7 @@ function removeCallback(err) { ...@@ -1632,7 +1624,7 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE; let reason = Notification.RemoveReason.CANCEL_REASON_REMOVE;
Notification.remove(hashCode, reason, removeCallback); Notification.remove(hashCode, reason, removeCallback);
``` ```
...@@ -1660,8 +1652,8 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1660,8 +1652,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**Example** **Example**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(hashCode, reason).then(() => { Notification.remove(hashCode, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
...@@ -1698,9 +1690,9 @@ function removeAllCallback(err) { ...@@ -1698,9 +1690,9 @@ function removeAllCallback(err) {
console.info("removeAll success"); console.info("removeAll success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.removeAll(bundle, removeAllCallback); Notification.removeAll(bundle, removeAllCallback);
``` ```
...@@ -1797,7 +1789,7 @@ function removeAllCallback(err) { ...@@ -1797,7 +1789,7 @@ function removeAllCallback(err) {
} }
} }
var userId = 1 let userId = 1;
Notification.removeAll(userId, removeAllCallback); Notification.removeAll(userId, removeAllCallback);
``` ```
...@@ -1822,7 +1814,7 @@ Removes all notifications for a specified user. This API uses a promise to retur ...@@ -1822,7 +1814,7 @@ Removes all notifications for a specified user. This API uses a promise to retur
**Example** **Example**
```js ```js
var userId = 1 let userId = 1;
Notification.removeAll(userId).then(() => { Notification.removeAll(userId).then(() => {
console.info("removeAll success"); console.info("removeAll success");
}); });
...@@ -1889,8 +1881,6 @@ Notification.getAllActiveNotifications().then((data) => { ...@@ -1889,8 +1881,6 @@ Notification.getAllActiveNotifications().then((data) => {
}); });
``` ```
## Notification.getActiveNotificationCount ## Notification.getActiveNotificationCount
getActiveNotificationCount(callback: AsyncCallback\<number\>): void getActiveNotificationCount(callback: AsyncCallback\<number\>): void
...@@ -2025,7 +2015,7 @@ function cancelGroupCallback(err) { ...@@ -2025,7 +2015,7 @@ function cancelGroupCallback(err) {
} }
} }
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName, cancelGroupCallback); Notification.cancelGroup(groupName, cancelGroupCallback);
``` ```
...@@ -2049,7 +2039,7 @@ Cancels notifications under a notification group of this application. This API u ...@@ -2049,7 +2039,7 @@ Cancels notifications under a notification group of this application. This API u
**Example** **Example**
```js ```js
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => { Notification.cancelGroup(groupName).then(() => {
console.info("cancelGroup success"); console.info("cancelGroup success");
}); });
...@@ -2088,8 +2078,8 @@ function removeGroupByBundleCallback(err) { ...@@ -2088,8 +2078,8 @@ function removeGroupByBundleCallback(err) {
} }
} }
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
``` ```
...@@ -2118,8 +2108,8 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -2118,8 +2108,8 @@ Removes notifications under a notification group of a specified application. Thi
**Example** **Example**
```js ```js
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => { Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
console.info("removeGroupByBundle success"); console.info("removeGroupByBundle success");
}); });
...@@ -2157,11 +2147,11 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2157,11 +2147,11 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
``` ```
...@@ -2189,11 +2179,11 @@ Sets the DND time. This API uses a promise to return the result. ...@@ -2189,11 +2179,11 @@ Sets the DND time. This API uses a promise to return the result.
**Example** **Example**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("setDoNotDisturbDate success"); console.info("setDoNotDisturbDate success");
}); });
...@@ -2231,13 +2221,13 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2231,13 +2221,13 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1
Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
``` ```
...@@ -2265,13 +2255,13 @@ Sets the DND time for a specified user. This API uses a promise to return the re ...@@ -2265,13 +2255,13 @@ Sets the DND time for a specified user. This API uses a promise to return the re
**Example** **Example**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1;
Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
console.info("setDoNotDisturbDate success"); console.info("setDoNotDisturbDate success");
...@@ -2370,7 +2360,7 @@ function getDoNotDisturbDateCallback(err,data) { ...@@ -2370,7 +2360,7 @@ function getDoNotDisturbDateCallback(err,data) {
} }
} }
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
``` ```
...@@ -2404,7 +2394,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the ...@@ -2404,7 +2394,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the
**Example** **Example**
```js ```js
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId).then((data) => { Notification.getDoNotDisturbDate(userId).then((data) => {
console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
...@@ -2492,7 +2482,7 @@ Checks whether a specified template exists. This API uses an asynchronous callba ...@@ -2492,7 +2482,7 @@ Checks whether a specified template exists. This API uses an asynchronous callba
**Example** **Example**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
function isSupportTemplateCallback(err, data) { function isSupportTemplateCallback(err, data) {
if (err.code) { if (err.code) {
console.info("isSupportTemplate failed " + JSON.stringify(err)); console.info("isSupportTemplate failed " + JSON.stringify(err));
...@@ -2529,7 +2519,7 @@ Checks whether a specified template exists. This API uses a promise to return th ...@@ -2529,7 +2519,7 @@ Checks whether a specified template exists. This API uses a promise to return th
**Example** **Example**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
Notification.isSupportTemplate(templateName).then((data) => { Notification.isSupportTemplate(templateName).then((data) => {
console.info("isSupportTemplate success, data: " + JSON.stringify(data)); console.info("isSupportTemplate success, data: " + JSON.stringify(data));
...@@ -2615,7 +2605,7 @@ function enabledNotificationCallback(err) { ...@@ -2615,7 +2605,7 @@ function enabledNotificationCallback(err) {
} }
}; };
var enable = true let enable = true;
Notification.enableDistributed(enable, enabledNotificationCallback); Notification.enableDistributed(enable, enabledNotificationCallback);
``` ```
...@@ -2643,7 +2633,7 @@ Sets whether this device supports distributed notifications. This API uses a pro ...@@ -2643,7 +2633,7 @@ Sets whether this device supports distributed notifications. This API uses a pro
**Example** **Example**
```javascript ```javascript
var enable = true let enable = true;
Notification.enableDistributed(enable).then(() => { Notification.enableDistributed(enable).then(() => {
console.info("enableDistributed success"); console.info("enableDistributed success");
}); });
...@@ -2734,11 +2724,11 @@ function enableDistributedByBundleCallback(err) { ...@@ -2734,11 +2724,11 @@ function enableDistributedByBundleCallback(err) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true;
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback); Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
``` ```
...@@ -2767,11 +2757,11 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2767,11 +2757,11 @@ Sets whether a specified application supports distributed notifications. This AP
**Example** **Example**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true;
Notification.enableDistributedByBundle(bundle, enable).then(() => { Notification.enableDistributedByBundle(bundle, enable).then(() => {
console.info("enableDistributedByBundle success"); console.info("enableDistributedByBundle success");
}); });
...@@ -2807,9 +2797,9 @@ function isDistributedEnabledByBundleCallback(err, data) { ...@@ -2807,9 +2797,9 @@ function isDistributedEnabledByBundleCallback(err, data) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
``` ```
...@@ -2843,9 +2833,9 @@ Checks whether a specified application supports distributed notifications. This ...@@ -2843,9 +2833,9 @@ Checks whether a specified application supports distributed notifications. This
**Example** **Example**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle).then((data) => { Notification.isDistributedEnabledByBundle(bundle).then((data) => {
console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data)); console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
...@@ -2947,9 +2937,9 @@ function callback(err) { ...@@ -2947,9 +2937,9 @@ function callback(err) {
} }
} }
// Bundle name of the application whose notification function is taken over by the reminder agent // Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// User ID // User ID
let userId = 100 let userId = 100;
// NotificationRequest object // NotificationRequest object
let request = { let request = {
id: 1, id: 1,
...@@ -2961,7 +2951,7 @@ let request = { ...@@ -2961,7 +2951,7 @@ let request = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(request, representativeBundle, userId, callback); Notification.publishAsBundle(request, representativeBundle, userId, callback);
``` ```
...@@ -2991,11 +2981,11 @@ Publishes a notification through the reminder agent. This API uses a promise to ...@@ -2991,11 +2981,11 @@ Publishes a notification through the reminder agent. This API uses a promise to
```js ```js
// Bundle name of the application whose notification function is taken over by the reminder agent // Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// User ID // User ID
let userId = 100 let userId = 100;
// NotificationRequest object // NotificationRequest object
var request = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -3005,7 +2995,7 @@ var request = { ...@@ -3005,7 +2995,7 @@ var request = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(request, representativeBundle, userId).then(() => { Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle success"); console.info("publishAsBundle success");
...@@ -3047,9 +3037,9 @@ function cancelAsBundleCallback(err) { ...@@ -3047,9 +3037,9 @@ function cancelAsBundleCallback(err) {
} }
} }
// Bundle name of the application whose notification function is taken over by the reminder agent // Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// User ID // User ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
``` ```
...@@ -3080,9 +3070,9 @@ Cancels a notification published by the reminder agent. This API uses a promise ...@@ -3080,9 +3070,9 @@ Cancels a notification published by the reminder agent. This API uses a promise
```js ```js
// Bundle name of the application whose notification function is taken over by the reminder agent // Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// User ID // User ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success"); console.info("cancelAsBundle success");
...@@ -3421,7 +3411,7 @@ function onConsumeCallback(data) { ...@@ -3421,7 +3411,7 @@ function onConsumeCallback(data) {
console.info('===> onConsume callback req.id:' + req.id); console.info('===> onConsume callback req.id:' + req.id);
}; };
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
...@@ -3460,7 +3450,7 @@ function onCancelCallback(data) { ...@@ -3460,7 +3450,7 @@ function onCancelCallback(data) {
console.info('===> onCancel callback req.id:' + req.id); console.info('===> onCancel callback req.id:' + req.id);
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
...@@ -3498,7 +3488,7 @@ function onUpdateCallback(map) { ...@@ -3498,7 +3488,7 @@ function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map)); console.info('===> onUpdateCallback map:' + JSON.stringify(map));
} }
var subscriber = { let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
...@@ -3530,7 +3520,7 @@ function onConnectCallback() { ...@@ -3530,7 +3520,7 @@ function onConnectCallback() {
console.info('===> onConnect in test'); console.info('===> onConnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
...@@ -3572,7 +3562,7 @@ function onDisconnectCallback() { ...@@ -3572,7 +3562,7 @@ function onDisconnectCallback() {
console.info('===> onDisconnect in test'); console.info('===> onDisconnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
...@@ -3608,7 +3598,7 @@ function onDestroyCallback() { ...@@ -3608,7 +3598,7 @@ function onDestroyCallback() {
console.info('===> onDestroy in test'); console.info('===> onDestroy in test');
} }
var subscriber = { let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
...@@ -3645,12 +3635,12 @@ function onDoNotDisturbDateChangeCallback(mode) { ...@@ -3645,12 +3635,12 @@ function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode); console.info('===> onDoNotDisturbDateChange:' + mode);
} }
var subscriber = { let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
...@@ -3695,12 +3685,12 @@ function onEnabledNotificationChangedCallback(callbackData) { ...@@ -3695,12 +3685,12 @@ function onEnabledNotificationChangedCallback(callbackData) {
console.info("enable: " + callbackData.enable); console.info("enable: " + callbackData.enable);
}; };
var subscriber = { let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
// Set the onEnabledNotificationChanged callback that is triggered when the notification enabled status changes. // Set the onEnabledNotificationChanged callback that is triggered when the notification enabled status changes.
......
...@@ -24,7 +24,7 @@ Publishes a notification. This API uses an asynchronous callback to return the r ...@@ -24,7 +24,7 @@ Publishes a notification. This API uses an asynchronous callback to return the r
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- | | -------- | ------------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| | request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -80,7 +80,7 @@ Publishes a notification. This API uses a promise to return the result. ...@@ -80,7 +80,7 @@ Publishes a notification. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- | | -------- | ------------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| | request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
**Error codes** **Error codes**
...@@ -132,7 +132,7 @@ Publishes a notification to a specified user. This API uses an asynchronous call ...@@ -132,7 +132,7 @@ Publishes a notification to a specified user. This API uses an asynchronous call
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| | request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
| userId | number | Yes | User ID. | | userId | number | Yes | User ID. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
...@@ -194,7 +194,7 @@ Publishes a notification to a specified user. This API uses a promise to return ...@@ -194,7 +194,7 @@ Publishes a notification to a specified user. This API uses a promise to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| | request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
| userId | number | Yes | User ID. | | userId | number | Yes | User ID. |
**Error codes** **Error codes**
...@@ -439,7 +439,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r ...@@ -439,7 +439,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot to add.| | slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Notification slot to add.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -488,7 +488,7 @@ Adds a notification slot. This API uses a promise to return the result. ...@@ -488,7 +488,7 @@ Adds a notification slot. This API uses a promise to return the result.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ---- | ---------------- | ---- | -------------------- | | ---- | ---------------- | ---- | -------------------- |
| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot to add.| | slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Notification slot to add.|
**Error codes** **Error codes**
...@@ -605,7 +605,7 @@ Adds an array of notification slots. This API uses an asynchronous callback to r ...@@ -605,7 +605,7 @@ Adds an array of notification slots. This API uses an asynchronous callback to r
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------ | | -------- | ------------------------- | ---- | ------------------------ |
| slots | Array\<[NotificationSlot](#notificationslot)\> | Yes | Notification slots to add.| | slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes | Notification slots to add.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -658,7 +658,7 @@ Adds an array of notification slots. This API uses a promise to return the resul ...@@ -658,7 +658,7 @@ Adds an array of notification slots. This API uses a promise to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----- | ------------------------- | ---- | ------------------------ | | ----- | ------------------------- | ---- | ------------------------ |
| slots | Array\<[NotificationSlot](#notificationslot)\> | Yes | Notification slots to add.| | slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes | Notification slots to add.|
**Error codes** **Error codes**
...@@ -701,7 +701,7 @@ Obtains a notification slot of a specified type. This API uses an asynchronous c ...@@ -701,7 +701,7 @@ Obtains a notification slot of a specified type. This API uses an asynchronous c
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | ----------------------------------------------------------- | | -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| | slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -783,7 +783,7 @@ Obtains all notification slots of this application. This API uses an asynchronou ...@@ -783,7 +783,7 @@ Obtains all notification slots of this application. This API uses an asynchronou
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | -------------------- | | -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | Yes | Callback used to return all notification slots of the current application.| | callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | Yes | Callback used to return all notification slots of the current application.|
**Error codes** **Error codes**
...@@ -823,7 +823,7 @@ Obtains all notification slots of this application. This API uses a promise to r ...@@ -823,7 +823,7 @@ Obtains all notification slots of this application. This API uses a promise to r
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return all notification slots of the current application.| | Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | Promise used to return all notification slots of the current application.|
**Error codes** **Error codes**
...@@ -1005,7 +1005,7 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -1005,7 +1005,7 @@ Sets whether to enable notification for a specified application. This API uses a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| enable | boolean | Yes | Whether to enable notification. | | enable | boolean | Yes | Whether to enable notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -1054,7 +1054,7 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -1054,7 +1054,7 @@ Sets whether to enable notification for a specified application. This API uses a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
| enable | boolean | Yes | Whether to enable notification. | | enable | boolean | Yes | Whether to enable notification. |
**Error codes** **Error codes**
...@@ -1097,7 +1097,7 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1097,7 +1097,7 @@ Checks whether notification is enabled for a specified application. This API use
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1145,7 +1145,7 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1145,7 +1145,7 @@ Checks whether notification is enabled for a specified application. This API use
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
**Return value** **Return value**
...@@ -1237,7 +1237,7 @@ Checks whether notification is enabled for the current application. This API use ...@@ -1237,7 +1237,7 @@ Checks whether notification is enabled for the current application. This API use
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
**Return value** **Return value**
...@@ -1282,7 +1282,7 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1282,7 +1282,7 @@ Sets whether to enable the notification badge for a specified application. This
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| enable | boolean | Yes | Whether to enable notification. | | enable | boolean | Yes | Whether to enable notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -1331,7 +1331,7 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1331,7 +1331,7 @@ Sets whether to enable the notification badge for a specified application. This
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
| enable | boolean | Yes | Whether to enable notification. | | enable | boolean | Yes | Whether to enable notification. |
**Error codes** **Error codes**
...@@ -1374,7 +1374,7 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1374,7 +1374,7 @@ Checks whether the notification badge is enabled for a specified application. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1422,7 +1422,7 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1422,7 +1422,7 @@ Checks whether the notification badge is enabled for a specified application. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
**Return value** **Return value**
...@@ -1470,8 +1470,8 @@ Sets the notification slot for a specified application. This API uses an asynchr ...@@ -1470,8 +1470,8 @@ Sets the notification slot for a specified application. This API uses an asynchr
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot. | | slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Notification slot. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1524,8 +1524,8 @@ Sets the notification slot for a specified application. This API uses a promise ...@@ -1524,8 +1524,8 @@ Sets the notification slot for a specified application. This API uses a promise
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot.| | slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Notification slot.|
**Error codes** **Error codes**
...@@ -1570,8 +1570,8 @@ Obtains the notification slots of a specified application. This API uses an asyn ...@@ -1570,8 +1570,8 @@ Obtains the notification slots of a specified application. This API uses an asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1618,13 +1618,13 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1618,13 +1618,13 @@ Obtains the notification slots of a specified application. This API uses a promi
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.| | Promise<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | Promise used to return the result.|
**Error codes** **Error codes**
...@@ -1666,7 +1666,7 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1666,7 +1666,7 @@ Obtains the number of notification slots of a specified application. This API us
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------- | | -------- | ------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| callback | AsyncCallback\<number\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<number\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1714,7 +1714,7 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1714,7 +1714,7 @@ Obtains the number of notification slots of a specified application. This API us
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle of the application.| | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.|
**Return value** **Return value**
...@@ -1763,7 +1763,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu ...@@ -1763,7 +1763,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1793,7 +1793,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ...@@ -1793,7 +1793,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\>
Obtains all active notifications. This API uses a promise to return the result. Obtains all active notifications. This API uses a promise to return the result.
...@@ -1807,7 +1807,7 @@ Obtains all active notifications. This API uses a promise to return the result. ...@@ -1807,7 +1807,7 @@ Obtains all active notifications. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.| | Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | Promise used to return the result.|
**Error codes** **Error codes**
...@@ -1915,7 +1915,7 @@ Obtains active notifications of this application. This API uses an asynchronous ...@@ -1915,7 +1915,7 @@ Obtains active notifications of this application. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1945,7 +1945,7 @@ Notification.getActiveNotifications(getActiveNotificationsCallback); ...@@ -1945,7 +1945,7 @@ Notification.getActiveNotifications(getActiveNotificationsCallback);
## Notification.getActiveNotifications ## Notification.getActiveNotifications
getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\>
Obtains active notifications of this application. This API uses a promise to return the result. Obtains active notifications of this application. This API uses a promise to return the result.
...@@ -1955,7 +1955,7 @@ Obtains active notifications of this application. This API uses a promise to ret ...@@ -1955,7 +1955,7 @@ Obtains active notifications of this application. This API uses a promise to ret
| Type | Description | | Type | Description |
| ------------------------------------------------------------ | --------------------------------------- | | ------------------------------------------------------------ | --------------------------------------- |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.| | Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | Promise used to return the result.|
**Error codes** **Error codes**
...@@ -1989,7 +1989,7 @@ Cancels notifications under a notification group of this application. This API u ...@@ -1989,7 +1989,7 @@ Cancels notifications under a notification group of this application. This API u
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------- | ---- | ---------------------------- | | --------- | --------------------- | ---- | ---------------------------- |
| groupName | string | Yes | Name of the notification group, which is specified through [NotificationRequest](#notificationrequest) when the notification is published.| | groupName | string | Yes | Name of the notification group, which is specified through [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) when the notification is published.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -2071,7 +2071,7 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -2071,7 +2071,7 @@ Removes notifications under a notification group of a specified application. Thi
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------- | ---- | ---------------------------- | | --------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| groupName | string | Yes | Name of the notification group. | | groupName | string | Yes | Name of the notification group. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -2121,7 +2121,7 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -2121,7 +2121,7 @@ Removes notifications under a notification group of a specified application. Thi
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------------ | ---- | -------------- | | --------- | ------------ | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| groupName | string | Yes | Name of the notification group.| | groupName | string | Yes | Name of the notification group.|
**Error codes** **Error codes**
...@@ -2987,7 +2987,7 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2987,7 +2987,7 @@ Sets whether a specified application supports distributed notifications. This AP
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| enable | boolean | Yes | Whether the application supports distributed notifications. | | enable | boolean | Yes | Whether the application supports distributed notifications. |
**Error codes** **Error codes**
...@@ -3032,7 +3032,7 @@ Checks whether a specified application supports distributed notifications. This ...@@ -3032,7 +3032,7 @@ Checks whether a specified application supports distributed notifications. This
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -3050,7 +3050,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3050,7 +3050,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example** **Example**
```javascript ```javascript
function isDistributedEnabledByBundleCallback(data) { function isDistributedEnabledByBundleCallback(err, data) {
if (err) { if (err) {
console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err)); console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
} else { } else {
...@@ -3083,7 +3083,7 @@ Checks whether a specified application supports distributed notifications. This ...@@ -3083,7 +3083,7 @@ Checks whether a specified application supports distributed notifications. This
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
**Return value** **Return value**
...@@ -3213,7 +3213,7 @@ Publishes a notification through the reminder agent. This API uses an asynchrono ...@@ -3213,7 +3213,7 @@ Publishes a notification through the reminder agent. This API uses an asynchrono
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- | | -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| | request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | | representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | User ID. | | userId | number | Yes | User ID. |
| callback | AsyncCallback | Yes | Callback used to return the result. | | callback | AsyncCallback | Yes | Callback used to return the result. |
...@@ -3280,7 +3280,7 @@ Publishes a notification through the reminder agent. This API uses a promise to ...@@ -3280,7 +3280,7 @@ Publishes a notification through the reminder agent. This API uses a promise to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| | request | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | | representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | User ID. | | userId | number | Yes | User ID. |
...@@ -3440,7 +3440,7 @@ Sets whether to enable a specified notification slot type for a specified applic ...@@ -3440,7 +3440,7 @@ Sets whether to enable a specified notification slot type for a specified applic
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. | | type | [SlotType](#slottype) | Yes | Notification slot type. |
| enable | boolean | Yes | Whether to enable the notification slot type. | | enable | boolean | Yes | Whether to enable the notification slot type. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -3491,7 +3491,7 @@ Sets whether to enable a specified notification slot type for a specified applic ...@@ -3491,7 +3491,7 @@ Sets whether to enable a specified notification slot type for a specified applic
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.| | type | [SlotType](#slottype) | Yes | Notification slot type.|
| enable | boolean | Yes | Whether to enable the notification slot type. | | enable | boolean | Yes | Whether to enable the notification slot type. |
...@@ -3534,7 +3534,7 @@ Checks whether a specified notification slot type is enabled for a specified app ...@@ -3534,7 +3534,7 @@ Checks whether a specified notification slot type is enabled for a specified app
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. | | type | [SlotType](#slottype) | Yes | Notification slot type. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
...@@ -3583,7 +3583,7 @@ Checks whether a specified notification slot type is enabled for a specified app ...@@ -3583,7 +3583,7 @@ Checks whether a specified notification slot type is enabled for a specified app
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.| | type | [SlotType](#slottype) | Yes | Notification slot type.|
**Return value** **Return value**
...@@ -3865,16 +3865,6 @@ Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { ...@@ -3865,16 +3865,6 @@ Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
| LEVEL_HIGH | 4 | Notification is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.| | LEVEL_HIGH | 4 | Notification is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.|
## BundleOption
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ------ | ------ |---- | --- | ------ |
| bundle | string | Yes | Yes | Bundle information of the application.|
| uid | number | Yes | Yes | User ID.|
## SlotType ## SlotType
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -3888,227 +3878,6 @@ Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { ...@@ -3888,227 +3878,6 @@ Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
| OTHER_TYPES | 0xFFFF | Notification slot for other purposes.| | OTHER_TYPES | 0xFFFF | Notification slot for other purposes.|
## NotificationActionButton
Describes the button displayed in the notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | Yes | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. |
| userInput | [NotificationUserInput](#notificationuserinput) | Yes | Yes | User input object. |
## NotificationBasicContent
Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
## NotificationLongTextContent
Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| longText | string | Yes | Yes | Long text of the notification. |
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent
Describes the multi-line text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| longTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. |
## NotificationPictureContent
Describe the picture-attached notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. |
## NotificationContent
Describes the notification content.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](#contenttype) | Yes | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. |
## NotificationFlagStatus
Describes the notification flag status.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------- | --- | --------------------------------- |
| TYPE_NONE | 0 | The default flag is used. |
| TYPE_OPEN | 1 | The notification flag is enabled. |
| TYPE_CLOSE | 2 | The notification flag is disabled. |
## NotificationFlags
Enumerates notification flags.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. |
## NotificationRequest
Describes the notification request.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | [NotificationContent](#notificationcontent) | Yes | Yes | Notification content. |
| id | number | Yes | Yes | Notification ID. |
| slotType | [SlotType](#slottype) | Yes | Yes | Notification slot type. |
| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. |
| deliveryTime | number | Yes | Yes | Time when the notification is sent. |
| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. |
| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked.|
| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. |
| color | number | Yes | Yes | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. |
| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. |
| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | Yes | Yes | Notification label. |
| badgeIconStyle | number | Yes | Yes | Notification badge type. |
| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. |
| actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | Yes | Yes | Buttons in the notification. Up to two buttons are allowed. |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | 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. |
| creatorUserId| number | Yes | No | ID of the user who creates the notification. |
| hashCode | string | Yes | No | Unique ID of the notification. |
| classification | string | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| groupName| string | Yes | Yes | Notification group name. |
| template | [NotificationTemplate](#notificationtemplate) | Yes | Yes | Notification template. |
| isRemoveAllowed | boolean | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| source | number | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| distributedOption | [DistributedOptions](#distributedoptions) | Yes | Yes | Distributed notification options. |
| deviceId | string | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| notificationFlags | [NotificationFlags](#notificationflags) | Yes | No | Notification flags. |
| removalWantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber | number | Yes | Yes | Number of notifications displayed on the application icon. |
## DistributedOptions
Describes distributed options.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed | boolean | Yes | Yes | Whether the notification is a distributed notification. |
| supportDisplayDevices | Array\<string> | Yes | Yes | List of the devices to which the notification can be synchronized. |
| supportOperateDevices | Array\<string> | Yes | Yes | List of the devices on which the notification can be opened. |
| remindType | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## NotificationSlot
Describes the notification slot.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | [SlotType](#slottype) | Yes | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc | string | Yes | Yes | Notification slot description. |
| badgeFlag | boolean | Yes | Yes | Whether to display the badge. |
| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | Yes | Yes | Whether vibration is enabled for the notification. |
| sound | string | Yes | Yes | Notification alert tone. |
| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. |
| lightColor | number | Yes | Yes | Indicator color of the notification. |
| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. |
| enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. |
## NotificationTemplate
Describes the notification template.
**System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.|
## NotificationUserInput
Provides the notification user input.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.|
## DeviceRemindType ## DeviceRemindType
......
# @ohos.notificationSubscribe (NotificationSubscribe) # @ohos.notificationSubscribe (NotificationSubscribe)
The **NotificationSubscribe** module provides APIs for notification subscription, notification unsubscription, subscription removal, and more. In general cases, only system applications can call these APIs. The **notificationSubscribe** module provides APIs for notification subscription, notification unsubscription, subscription removal, and more. In general cases, only system applications can call these APIs.
> **NOTE** > **NOTE**
> >
...@@ -9,7 +9,7 @@ The **NotificationSubscribe** module provides APIs for notification subscription ...@@ -9,7 +9,7 @@ The **NotificationSubscribe** module provides APIs for notification subscription
## Modules to Import ## Modules to Import
```js ```js
import NotificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
``` ```
...@@ -30,8 +30,8 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -30,8 +30,8 @@ Subscribes to a notification with the subscription information specified. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ---------------- | | ---------- | ------------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | Yes | Notification subscriber. |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes | Notification subscription information.| | info | [NotificationSubscribeInfo](js-apis-notification.md#notificationsubscribeinfo) | Yes | Notification subscription information.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -50,7 +50,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -50,7 +50,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
// subscribe callback // subscribe callback
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribe success"); console.info("subscribe success");
} }
...@@ -64,11 +64,9 @@ let subscriber = { ...@@ -64,11 +64,9 @@ let subscriber = {
let info = { let info = {
bundleNames: ["bundleName1","bundleName2"] bundleNames: ["bundleName1","bundleName2"]
}; };
NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); notificationSubscribe.subscribe(subscriber, info, subscribeCallback);
``` ```
## NotificationSubscribe.subscribe ## NotificationSubscribe.subscribe
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
...@@ -85,7 +83,7 @@ Subscribes to notifications of all applications under this user. This API uses a ...@@ -85,7 +83,7 @@ Subscribes to notifications of all applications under this user. This API uses a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ---------------------- | ---- | ---------------- | | ---------- | ---------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | Yes | Notification subscriber. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -103,7 +101,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -103,7 +101,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribe success"); console.info("subscribe success");
} }
...@@ -114,7 +112,7 @@ function onConsumeCallback(data) { ...@@ -114,7 +112,7 @@ function onConsumeCallback(data) {
let subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -135,8 +133,8 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -135,8 +133,8 @@ Subscribes to a notification with the subscription information specified. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------ | | ---------- | ------------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber.| | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | Yes | Notification subscriber.|
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No | Notification subscription information. | | info | [NotificationSubscribeInfo](js-apis-notification.md#notificationsubscribeinfo) | No | Notification subscription information. |
**Error codes** **Error codes**
...@@ -157,7 +155,7 @@ function onConsumeCallback(data) { ...@@ -157,7 +155,7 @@ function onConsumeCallback(data) {
let subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber).then(() => { notificationSubscribe.subscribe(subscriber).then(() => {
console.info("subscribe success"); console.info("subscribe success");
}); });
``` ```
...@@ -180,7 +178,7 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu ...@@ -180,7 +178,7 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ---------------------- | ---- | -------------------- | | ---------- | ---------------------- | ---- | -------------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | Yes | Notification subscriber. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -198,22 +196,20 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -198,22 +196,20 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
function unsubscribeCallback(err) { function unsubscribeCallback(err) {
if (err) { if (err) {
console.info("unsubscribe failed " + JSON.stringify(err)); console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("unsubscribe success"); console.info("unsubscribe success");
} }
} }
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
let subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
## NotificationSubscribe.unsubscribe ## NotificationSubscribe.unsubscribe
unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
...@@ -230,7 +226,7 @@ Unsubscribes from a notification. This API uses a promise to return the result. ...@@ -230,7 +226,7 @@ Unsubscribes from a notification. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ---------------------- | ---- | ------------ | | ---------- | ---------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber.| | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | Yes | Notification subscriber.|
**Error codes** **Error codes**
...@@ -245,19 +241,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -245,19 +241,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
**Example** **Example**
```js ```js
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
let subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
NotificationSubscribe.unsubscribe(subscriber).then(() => { notificationSubscribe.unsubscribe(subscriber).then(() => {
console.info("unsubscribe success"); console.info("unsubscribe success");
}); });
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void
...@@ -274,8 +268,8 @@ Removes a notification for a specified application. This API uses an asynchronou ...@@ -274,8 +268,8 @@ Removes a notification for a specified application. This API uses an asynchronou
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ----------------------------------| ---- | -------------------- | | --------------- | ----------------------------------| ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | | notificationKey | [NotificationKey](js-apis-notification.md#notificationkey) | Yes | Notification key. |
| reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -296,7 +290,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -296,7 +290,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
function removeCallback(err) { function removeCallback(err) {
if (err) { if (err) {
console.info("remove failed " + JSON.stringify(err)); console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("remove success"); console.info("remove success");
} }
...@@ -308,8 +302,8 @@ let notificationKey = { ...@@ -308,8 +302,8 @@ let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
}; };
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); notificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
``` ```
...@@ -330,8 +324,8 @@ Removes a notification for a specified application. This API uses a promise to r ...@@ -330,8 +324,8 @@ Removes a notification for a specified application. This API uses a promise to r
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | --------------- | ---- | ---------- | | --------------- | --------------- | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| | bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.|
| notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | | notificationKey | [NotificationKey]((js-apis-notification.md#notificationkey)) | Yes | Notification key. |
| reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. |
**Error codes** **Error codes**
...@@ -357,13 +351,11 @@ let notificationKey = { ...@@ -357,13 +351,11 @@ let notificationKey = {
label: "label", label: "label",
}; };
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => { notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void
...@@ -380,7 +372,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu ...@@ -380,7 +372,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | Yes | Unique notification ID. It is the **hashCode** in the [NotificationRequest](#notificationrequest) object of [SubscribeCallbackData](#subscribecallbackdata) of the [onConsume](#onconsume) callback.| | hashCode | string | Yes | Unique notification ID. It is the value of **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) in the [onConsume](#onconsume) callback. |
| reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -402,17 +394,15 @@ let hashCode = 'hashCode'; ...@@ -402,17 +394,15 @@ let hashCode = 'hashCode';
function removeCallback(err) { function removeCallback(err) {
if (err) { if (err) {
console.info("remove failed " + JSON.stringify(err)); console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("remove success"); console.info("remove success");
} }
} }
let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason, removeCallback); notificationSubscribe.remove(hashCode, reason, removeCallback);
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason): Promise\<void\> remove(hashCode: string, reason: RemoveReason): Promise\<void\>
...@@ -447,14 +437,12 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -447,14 +437,12 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
let hashCode = 'hashCode'; let hashCode = 'hashCode';
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason).then(() => { notificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
...@@ -471,7 +459,7 @@ Removes all notifications for a specified application. This API uses an asynchro ...@@ -471,7 +459,7 @@ Removes all notifications for a specified application. This API uses an asynchro
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------- | | -------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption]((js-apis-inner-notification-notificationCommonDef.md#bundleoption)) | Yes | Bundle information of the application. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -490,7 +478,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -490,7 +478,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
...@@ -501,8 +489,6 @@ let bundle = { ...@@ -501,8 +489,6 @@ let bundle = {
NotificationSubscribe.removeAll(bundle, removeAllCallback); NotificationSubscribe.removeAll(bundle, removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(callback: AsyncCallback\<void\>): void removeAll(callback: AsyncCallback\<void\>): void
...@@ -536,17 +522,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -536,17 +522,15 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
} }
NotificationSubscribe.removeAll(removeAllCallback); notificationSubscribe.removeAll(removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(bundle?: BundleOption): Promise\<void\> removeAll(bundle?: BundleOption): Promise\<void\>
...@@ -563,7 +547,7 @@ Removes all notifications for a specified application. This API uses a promise t ...@@ -563,7 +547,7 @@ Removes all notifications for a specified application. This API uses a promise t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | No | Bundle information of the application.| | bundle | [BundleOption]((js-apis-inner-notification-notificationCommonDef.md#bundleoption)) | No | Bundle information of the application.|
**Error codes** **Error codes**
...@@ -580,7 +564,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -580,7 +564,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
// If no application is specified, notifications of all applications are deleted. // If no application is specified, notifications of all applications are deleted.
NotificationSubscribe.removeAll().then(() => { notificationSubscribe.removeAll().then(() => {
console.info("removeAll success"); console.info("removeAll success");
}); });
``` ```
...@@ -620,7 +604,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -620,7 +604,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
...@@ -628,7 +612,7 @@ function removeAllCallback(err) { ...@@ -628,7 +612,7 @@ function removeAllCallback(err) {
let userId = 1; let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## Notification.removeAll ## Notification.removeAll
...@@ -665,7 +649,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -665,7 +649,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
...@@ -673,11 +657,9 @@ function removeAllCallback(err) { ...@@ -673,11 +657,9 @@ function removeAllCallback(err) {
let userId = 1; let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## NotificationSubscriber ## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe). Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).
...@@ -686,7 +668,7 @@ Provides callbacks for receiving or removing notifications and serves as the inp ...@@ -686,7 +668,7 @@ Provides callbacks for receiving or removing notifications and serves as the inp
### onConsume ### onConsume
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Callback for receiving notifications. Callback for receiving notifications.
...@@ -698,14 +680,14 @@ Callback for receiving notifications. ...@@ -698,14 +680,14 @@ Callback for receiving notifications.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification received.| | data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification received.|
**Example** **Example**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -721,12 +703,12 @@ let subscriber = { ...@@ -721,12 +703,12 @@ let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onCancel ### onCancel
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Callback for canceling notifications. Callback for canceling notifications.
...@@ -738,14 +720,14 @@ Callback for canceling notifications. ...@@ -738,14 +720,14 @@ Callback for canceling notifications.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification to cancel.| | data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification to cancel.|
**Example** **Example**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -761,12 +743,12 @@ let subscriber = { ...@@ -761,12 +743,12 @@ let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onUpdate ### onUpdate
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
Callback for notification sorting updates. Callback for notification sorting updates.
...@@ -778,14 +760,14 @@ Callback for notification sorting updates. ...@@ -778,14 +760,14 @@ Callback for notification sorting updates.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Latest notification sorting list.| | data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) | Yes| Latest notification sorting list.|
**Example** **Example**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -799,7 +781,7 @@ let subscriber = { ...@@ -799,7 +781,7 @@ let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onConnect ### onConnect
...@@ -817,7 +799,7 @@ Callback for subscription. ...@@ -817,7 +799,7 @@ Callback for subscription.
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -831,7 +813,7 @@ let subscriber = { ...@@ -831,7 +813,7 @@ let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDisconnect ### onDisconnect
...@@ -849,14 +831,14 @@ Callback for unsubscription. ...@@ -849,14 +831,14 @@ Callback for unsubscription.
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
}; };
function unsubscribeCallback(err) { function unsubscribeCallback(err) {
if (err.code) { if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err)); console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("unsubscribeCallback"); console.info("unsubscribeCallback");
} }
...@@ -875,9 +857,9 @@ let subscriber = { ...@@ -875,9 +857,9 @@ let subscriber = {
}; };
// The onConnect callback is invoked when subscription to the notification is complete. // The onConnect callback is invoked when subscription to the notification is complete.
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete. // The onDisconnect callback is invoked when unsubscription to the notification is complete.
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
### onDestroy ### onDestroy
...@@ -895,7 +877,7 @@ Callback for service disconnection. ...@@ -895,7 +877,7 @@ Callback for service disconnection.
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -909,7 +891,7 @@ let subscriber = { ...@@ -909,7 +891,7 @@ let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDoNotDisturbDateChange ### onDoNotDisturbDateChange
...@@ -933,7 +915,7 @@ Callback for DND time setting updates. ...@@ -933,7 +915,7 @@ Callback for DND time setting updates.
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -947,13 +929,13 @@ let subscriber = { ...@@ -947,13 +929,13 @@ let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onEnabledNotificationChanged ### onEnabledNotificationChanged
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata)) => void onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)) => void
Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result. Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result.
...@@ -965,14 +947,14 @@ Listens for the notification enabled status changes. This API uses an asynchrono ...@@ -965,14 +947,14 @@ Listens for the notification enabled status changes. This API uses an asynchrono
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata)\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)\> | Yes| Callback used to return the result.|
**Example** **Example**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -988,115 +970,69 @@ let subscriber = { ...@@ -988,115 +970,69 @@ let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
## BundleOption ### onBadgeChanged<sup>10+</sup>
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ------ | ------ |---- | --- | ------ |
| bundle | string | Yes | Yes | Bundle information of the application.|
| uid | number | Yes | Yes | User ID.|
## NotificationKey
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ----- | ------ | ---- | --- | -------- |
| id | number | Yes | Yes | Notification ID. |
| label | string | Yes | Yes | Notification label.|
## SubscribeCallbackData
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable | Writable | Description |
| --------------- | ------------------------------------------------- | -------- | -------- | -------- |
| request | [NotificationRequest](js-apis-notificationManager.md#notificationrequest) | Yes| No| Notification content.|
| sortingMap | [NotificationSortingMap](#notificationsortingmap) | Yes| No| Notification sorting information.|
| reason | number | Yes | No | Reason for deletion.|
| sound | string | Yes | No | Sound used for notification.|
| vibrationValues | Array\<number\> | Yes | No | Vibration used for notification.|
onBadgeChanged?:(data: [BadgeNumberCallbackData](#badgenumbercallbackdata)) => void
## EnabledNotificationCallbackData Listens for the change of the notification badge number.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable | Writable | Description | **Parameters**
| ------ | ------- | ---------------- | ---------------- | ---------------- |
| bundle | string | Yes| No| Bundle name of the application. |
| uid | number | Yes| No| UID of the application. |
| enable | boolean | Yes| No| Notification enabled status of the application.|
## NotificationSorting | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[BadgeNumberCallbackData](#badgenumbercallbackdata)\> | Yes | Callback used to return the result.|
Provides sorting information of active notifications. **Example**
**System capability**: SystemCapability.Notification.Notification ```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
**System API**: This is a system API and cannot be called by third-party applications. function onBadgeChangedCallback(data) {
console.info("bundle: ", data.bundle);
console.info("uid: ", data.uid);
console.info("badgeNumber: ", data.badgeNumber);
};
| Name | Type | Readable| Writable| Description | let subscriber = {
| -------- | ------------------------------------- | ---- | --- | ------------ | onBadgeChanged: onBadgeChangedCallback
| slot | [NotificationSlot](js-apis-notificationManager.md#notificationslot) | Yes | No | Notification slot.| };
| hashCode | string | Yes | No | Unique ID of the notification.|
| ranking | number | Yes | No | Notification sequence number.|
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
## NotificationSortingMap
Provides sorting information of active notifications in all subscribed notifications. ## RemoveReason
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description | | Name | Value | Description |
| -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- | | -------------------- | --- | -------------------- |
| sortings | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | No | Array of notification sorting information.| | CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. |
| sortedHashCode | Array\<string\> | Yes | No | Array of unique notification IDs.| | CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. |
## NotificationSubscribeInfo
Provides the information about the publisher for notification subscription. ## BadgeNumberCallbackData<sup>10+</sup>
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------- | --------------- | --- | ---- | ------------------------------- | | ----------- | ------ | ---- | ---- | ------------ |
| bundleNames | Array\<string\> | Yes | Yes | Bundle names of the applications whose notifications are to be subscribed to.| | bundle | string | Yes | No | Bundle name of the application.|
| userId | number | Yes | Yes | User whose notifications are to be subscribed to. | | uid | number | Yes | No | UID of the application. |
| badgeNumber | number | Yes | No | Notification badge number. |
## NotificationUserInput
Provides the notification user input.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.|
## RemoveReason
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. |
| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. |
# @system.notification # @system.notification (Notification)
> **NOTE** > **NOTE**
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.notification`](js-apis-notification.md). > - The APIs of this module are no longer maintained since API version 7. You are advised to use [@ohos.notification](js-apis-notification.md).
> >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -17,22 +17,22 @@ import notification from '@system.notification'; ...@@ -17,22 +17,22 @@ import notification from '@system.notification';
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable | Writable | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------------------------------- | ---- | ------------------------- | ------------------------- | ------------------------- | | ----------- | ---------------------------------------------- | ---- | ------------------------- |
| bundleName | string | Yes | Yes | Yes | Name of the application bundle to which the notification will be redirected after being clicked. | | bundleName | string | Yes | Name of the application bundle to which the notification will be redirected after being clicked. |
| abilityName | string | Yes | Yes | Yes | Name of the application ability to which the notification will be redirected after being clicked.| | abilityName | string | Yes | Name of the application ability to which the notification will be redirected after being clicked.|
| uri | string | Yes | Yes | No | URI of the page to be redirected to. | | uri | string | No | URI of the page to be redirected to. |
## ShowNotificationOptions ## ShowNotificationOptions
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable | Writable | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ---------------------------------------------- | ---- | ------------------------- | ------------------------- | ------------------------- | | ------------- | ---------------------------------------------- | ---- | ------------------------- |
| contentTitle | string | Yes | Yes | No | Notification title. | | contentTitle | string | No | Notification title. |
| contentText | string | Yes | Yes | No | Notification content. | | contentText | string | No | Notification content. |
| clickAction | ActionResult | Yes | Yes | No | Action triggered when the notification is clicked. | | clickAction | ActionResult | No | Action triggered when the notification is clicked. |
## notification.show ## notification.show
...@@ -59,9 +59,9 @@ export default { ...@@ -59,9 +59,9 @@ export default {
clickAction: { clickAction: {
bundleName: 'com.example.testapp', bundleName: 'com.example.testapp',
abilityName: 'notificationDemo', abilityName: 'notificationDemo',
uri: '/path/to/notification', uri: '/path/to/notification'
}, }
}); });
}, }
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册