You need to sign in or sign up before continuing.
未验证 提交 ba510b9d 编写于 作者: O openharmony_ci 提交者: Gitee

!18724 翻译完成 17712+18341+17997

Merge pull request !18724 from ester.zhou/TR-17712
...@@ -309,7 +309,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json ...@@ -309,7 +309,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)| | continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuring rule:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)| | [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuration rules:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
| backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)| | backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No|
| startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No|
......
...@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers ...@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers
* The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail. * The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail.
* Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail. * Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail.
* The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail. * The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail.
* Installing an application update will delete quick fix package. * Installing an application update will delete the quick fix package.
## Structure of the Quick Fix Package ## Structure of the Quick Fix Package
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## Creating a JavaScript Project ## Creating a JavaScript Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
The **CommonEvent** module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events, as well obtaining and setting the common event result code and result data. The **CommonEvent** module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events, as well obtaining and setting the common event result code and result data.
> **NOTE** > **NOTE**
>
> - The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.commonEventManager](js-apis-commonEventManager.md). > - The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.commonEventManager](js-apis-commonEventManager.md).
> >
> - 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. > - 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.
...@@ -19,14 +20,16 @@ A system common event is an event that is published by a system service or syste ...@@ -19,14 +20,16 @@ A system common event is an event that is published by a system service or syste
For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md). For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md).
## CommonEvent.publish ## CommonEvent.publish<sup>(deprecated)</sup>
```ts publish(event: string, callback: AsyncCallback\<void>): void
publish(event: string, callback: AsyncCallback<void>): void
```
Publishes a common event. This API uses an asynchronous callback to return the result. Publishes a common event. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -52,14 +55,16 @@ function publishCB(err) { ...@@ -52,14 +55,16 @@ function publishCB(err) {
CommonEvent.publish("event", publishCB); CommonEvent.publish("event", publishCB);
``` ```
## CommonEvent.publish ## CommonEvent.publish<sup>(deprecated)</sup>
```ts publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
Publishes a common event with given attributes. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -68,7 +73,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca ...@@ -68,7 +73,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| event | string | Yes | Name of the common event to publish. | | event | string | Yes | Name of the common event to publish. |
| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.| | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.|
| callback | syncCallback\<void> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -94,14 +99,16 @@ function publishCB(err) { ...@@ -94,14 +99,16 @@ function publishCB(err) {
CommonEvent.publish("event", options, publishCB); CommonEvent.publish("event", options, publishCB);
``` ```
## CommonEvent.publishAsUser<sup>8+</sup> ## CommonEvent.publishAsUser<sup>(deprecated)</sup>
```ts publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void
publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): void
```
Publishes a common event to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**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.
...@@ -133,14 +140,16 @@ let userId = 100; ...@@ -133,14 +140,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, publishCB); CommonEvent.publishAsUser("event", userId, publishCB);
``` ```
## CommonEvent.publishAsUser<sup>8+</sup> ## CommonEvent.publishAsUser<sup>(deprecated)</sup>
```ts publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**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.
...@@ -180,14 +189,16 @@ let userId = 100; ...@@ -180,14 +189,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, options, publishCB); CommonEvent.publishAsUser("event", userId, options, publishCB);
``` ```
## CommonEvent.createSubscriber ## CommonEvent.createSubscriber<sup>(deprecated)</sup>
```ts createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback<CommonEventSubscriber>): void
```
Creates a subscriber. This API uses an asynchronous callback to return the result. Creates a subscriber. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -222,14 +233,16 @@ function createCB(err, commonEventSubscriber) { ...@@ -222,14 +233,16 @@ function createCB(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createCB); CommonEvent.createSubscriber(subscribeInfo, createCB);
``` ```
## CommonEvent.createSubscriber ## CommonEvent.createSubscriber<sup>(deprecated)</sup>
```ts createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSubscriber>
```
Creates a subscriber. This API uses a promise to return the result. Creates a subscriber. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -262,14 +275,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => { ...@@ -262,14 +275,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
}); });
``` ```
## CommonEvent.subscribe ## CommonEvent.subscribe<sup>(deprecated)</sup>
```ts subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEventData>): void
```
Subscribes to common events. This API uses an asynchronous callback to return the result. Subscribes to common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagersubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -314,14 +329,16 @@ function createCB(err, commonEventSubscriber) { ...@@ -314,14 +329,16 @@ function createCB(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createCB); CommonEvent.createSubscriber(subscribeInfo, createCB);
``` ```
## CommonEvent.unsubscribe ## CommonEvent.unsubscribe<sup>(deprecated)</sup>
```ts unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback<void>): void
```
Unsubscribes from common events. This API uses an asynchronous callback to return the result. Unsubscribes from common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagerunsubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
......
...@@ -39,7 +39,6 @@ Publishes a common event and executes an asynchronous callback after the event i ...@@ -39,7 +39,6 @@ Publishes a common event and executes an asynchronous callback after the event i
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. | | 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -87,7 +86,6 @@ Publishes a common event with given attributes. This API uses an asynchronous ca ...@@ -87,7 +86,6 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. | | 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -144,8 +142,6 @@ Publishes a common event to a specific user. This API uses an asynchronous callb ...@@ -144,8 +142,6 @@ Publishes a common event to a specific user. This API uses an asynchronous callb
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. | | 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -199,9 +195,7 @@ Publishes a common event with given attributes to a specific user. This API uses ...@@ -199,9 +195,7 @@ Publishes a common event with given attributes to a specific user. This API uses
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 202 | not system app. | | 1500004 | not System services or System app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -251,17 +245,8 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul ...@@ -251,17 +245,8 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
```ts ```ts
let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
...@@ -307,14 +292,6 @@ Creates a subscriber. This API uses a promise to return the result. ...@@ -307,14 +292,6 @@ Creates a subscriber. This API uses a promise to return the result.
| --------------------------------------------------------- | ---------------- | | --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.| | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
```ts ```ts
...@@ -356,7 +333,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th ...@@ -356,7 +333,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. | | 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -426,7 +402,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur ...@@ -426,7 +402,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. | | 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -495,6 +470,8 @@ Removes a sticky common event. This API uses an asynchronous callback to return ...@@ -495,6 +470,8 @@ Removes a sticky common event. This API uses an asynchronous callback to return
**Required permissions**: ohos.permission.COMMONEVENT_STICKY **Required permissions**: ohos.permission.COMMONEVENT_STICKY
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -508,12 +485,9 @@ Removes a sticky common event. This API uses an asynchronous callback to return ...@@ -508,12 +485,9 @@ Removes a sticky common event. This API uses an asynchronous callback to return
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. | | 1500004 | not system service. |
| 1500007 | The message send error. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | The CEMS error. | | 1500008 | Common Event Service does not complete initialization. |
**Example** **Example**
...@@ -525,7 +499,6 @@ CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => { ...@@ -525,7 +499,6 @@ CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => {
return; return;
} }
console.info(`Remove sticky event AsyncCallback success`); console.info(`Remove sticky event AsyncCallback success`);
}
}); });
``` ```
...@@ -539,6 +512,8 @@ Removes a sticky common event. This API uses a promise to return the result. ...@@ -539,6 +512,8 @@ Removes a sticky common event. This API uses a promise to return the result.
**Required permissions**: ohos.permission.COMMONEVENT_STICKY **Required permissions**: ohos.permission.COMMONEVENT_STICKY
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
...@@ -557,20 +532,102 @@ Removes a sticky common event. This API uses a promise to return the result. ...@@ -557,20 +532,102 @@ Removes a sticky common event. This API uses a promise to return the result.
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. | | 1500004 | not system service. |
| 1500007 | The message send error. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | The CEMS error. | | 1500008 | Common Event Service does not complete initialization. |
**Example** **Example**
```ts ```ts
commonEventManager.removeStickyCommonEvent("sticky_event").then(() => { CommonEventManager.removeStickyCommonEvent("sticky_event").then(() => {
console.info(`Remove sticky event AsyncCallback success`); console.info(`Remove sticky event AsyncCallback success`);
}).catch ((err) => { }).catch ((err) => {
console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`); console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`);
}); });
``` ```
## CommonEventManager.setStaticSubscriberState<sup>10+</sup>
setStaticSubscriberState(enable: boolean, callback: AsyncCallback\<void>): void;
Enables or disables static subscription for the current application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------- |
| enable | boolean | Yes | Whether static subscription is enabled.<br> **true**: enabled.<br>**false**: disabled.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example**
```ts
CommonEventManager.setStaticSubscriberState(true, (err) => {
if (!err) {
console.info(`Set static subscriber state callback failed, err is null.`);
return;
}
if (err.code) {
console.info(`Set static subscriber state callback failed, errCode: ${err.code}, errMes: ${err.message}`);
return;
}
console.info(`Set static subscriber state callback success`);
});
```
## CommonEventManager.setStaticSubscriberState<sup>10+</sup>
setStaticSubscriberState(enable: boolean): Promise\<void>;
Enables or disables static subscription for the current application. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------- |
| enable | boolean | Yes | Whether static subscription is enabled.<br> **true**: enabled.<br>**false**: disabled.|
**Return value**
| Type | Description |
| -------------- | ---------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example**
```ts
CommonEventManager.setStaticSubscriberState(false).then(() => {
console.info(`Set static subscriber state promise success`);
}).catch ((err) => {
console.info(`Set static subscriber state promise failed, errCode: ${err.code}, errMes: ${err.message}`);
});
```
# CommonEventData # CommonEventData
> **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.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventPublishData # CommonEventPublishData
> **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.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventSubscribeInfo # CommonEventSubscribeInfo
> **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.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventSubscriber # CommonEventSubscriber
## getCode > **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.
## Usage
Before using the **CommonEventSubscriber** module, you must obtain a **subscriber** object by calling **CommonEvent.createSubscriber**.
```ts ```ts
getCode(callback: AsyncCallback<number>): void import CommonEvent from '@ohos.commonEvent';
let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
let subscribeInfo = {
events: ["event"]
};
// Callback for subscriber creation.
function createCB(err, commonEventSubscriber) {
if (err.code) {
console.error(`createSubscriber failed, code is ${err.code}`);
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
}
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, createCB);
``` ```
## getCode
getCode(callback: AsyncCallback\<number>): void
Obtains the code of this common event. This API uses an asynchronous callback to return the result. Obtains the code of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
...@@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to ...@@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code obtaining of an ordered common event. // Callback for result code obtaining of an ordered common event.
function getCodeCB(err, code) { function getCodeCB(err, code) {
if (err.code) { if (err.code) {
...@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB); ...@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB);
## getCode ## getCode
```ts getCode(): Promise\<number>
getCode(): Promise<number>
```
Obtains the code of this common event. This API uses a promise to return the result. Obtains the code of this common event. This API uses a promise to return the result.
...@@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res ...@@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getCode().then((code) => { subscriber.getCode().then((code) => {
console.info("getCode " + JSON.stringify(code)); console.info("getCode " + JSON.stringify(code));
}).catch((err) => { }).catch((err) => {
...@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => { ...@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => {
## setCode ## setCode
```ts setCode(code: number, callback: AsyncCallback\<void>): void
setCode(code: number, callback: AsyncCallback<void>): void
```
Sets the code for this common event. This API uses an asynchronous callback to return the result. Sets the code for this common event. This API uses an asynchronous callback to return the result.
...@@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r ...@@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code setting of an ordered common event. // Callback for result code setting of an ordered common event.
function setCodeCB(err) { function setCodeCB(err) {
if (err.code) { if (err.code) {
...@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB); ...@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB);
## setCode ## setCode
```ts setCode(code: number): Promise\<void>
setCode(code: number): Promise<void>
```
Sets the code for this common event. This API uses a promise to return the result. Sets the code for this common event. This API uses a promise to return the result.
...@@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul ...@@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCode(1).then(() => { subscriber.setCode(1).then(() => {
console.info("setCode"); console.info("setCode");
}).catch((err) => { }).catch((err) => {
...@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => { ...@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => {
## getData ## getData
```ts getData(callback: AsyncCallback\<string>): void
getData(callback: AsyncCallback<string>): void
```
Obtains the data of this common event. This API uses an asynchronous callback to return the result. Obtains the data of this common event. This API uses an asynchronous callback to return the result.
...@@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to ...@@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data obtaining of an ordered common event. // Callback for result data obtaining of an ordered common event.
function getDataCB(err, data) { function getDataCB(err, data) {
if (err.code) { if (err.code) {
...@@ -161,9 +172,7 @@ subscriber.getData(getDataCB); ...@@ -161,9 +172,7 @@ subscriber.getData(getDataCB);
## getData ## getData
```ts getData(): Promise\<string>
getData(): Promise<string>
```
Obtains the data of this common event. This API uses a promise to return the result. Obtains the data of this common event. This API uses a promise to return the result.
...@@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res ...@@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getData().then((data) => { subscriber.getData().then((data) => {
console.info("getData " + JSON.stringify(data)); console.info("getData " + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
...@@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r ...@@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setDataCB(err) { function setDataCB(err) {
if (err.code) { if (err.code) {
...@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB); ...@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB);
## setData ## setData
```ts setData(data: string): Promise\<void>
setData(data: string): Promise<void>
```
Sets the data for this common event. This API uses a promise to return the result. Sets the data for this common event. This API uses a promise to return the result.
...@@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul ...@@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setData("publish_data_changed").then(() => { subscriber.setData("publish_data_changed").then(() => {
console.info("setData"); console.info("setData");
}).catch((err) => { }).catch((err) => {
...@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => { ...@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => {
## setCodeAndData ## setCodeAndData
```ts setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
```
Sets the code and data for this common event. This API uses an asynchronous callback to return the result. Sets the code and data for this common event. This API uses an asynchronous callback to return the result.
...@@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call ...@@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for code and data setting of an ordered common event. // Callback for code and data setting of an ordered common event.
function setCodeDataCB(err) { function setCodeDataCB(err) {
if (err.code) { if (err.code) {
...@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB); ...@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB);
## setCodeAndData ## setCodeAndData
```ts setCodeAndData(code: number, data: string): Promise\<void>
setCodeAndData(code: number, data: string): Promise<void>
```
Sets the code and data for this common event. This API uses a promise to return the result. Sets the code and data for this common event. This API uses a promise to return the result.
...@@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return ...@@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => { subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData"); console.info("setCodeAndData");
}).catch((err) => { }).catch((err) => {
...@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => { ...@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
## isOrderedCommonEvent ## isOrderedCommonEvent
```ts isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result. Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
...@@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou ...@@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is an ordered one. // Callback for checking whether the current common event is an ordered one.
function isOrderedCB(err, isOrdered) { function isOrderedCB(err, isOrdered) {
if (err.code) { if (err.code) {
...@@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB); ...@@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB);
## isOrderedCommonEvent ## isOrderedCommonEvent
```ts isOrderedCommonEvent(): Promise\<boolean>
isOrderedCommonEvent(): Promise<boolean>
```
Checks whether this common event is an ordered one. This API uses a promise to return the result. Checks whether this common event is an ordered one. This API uses a promise to return the result.
...@@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r ...@@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.isOrderedCommonEvent().then((isOrdered) => { subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered)); console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => { }).catch((err) => {
...@@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => { ...@@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => {
## isStickyCommonEvent ## isStickyCommonEvent
```ts isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
isStickyCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result. Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
...@@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous ...@@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is a sticky one. // Callback for checking whether the current common event is a sticky one.
function isStickyCB(err, isSticky) { function isStickyCB(err, isSticky) {
if (err.code) { if (err.code) {
...@@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB); ...@@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB);
## isStickyCommonEvent ## isStickyCommonEvent
```ts isStickyCommonEvent(): Promise\<boolean>
isStickyCommonEvent(): Promise<boolean>
```
Checks whether this common event is a sticky one. This API uses a promise to return the result. Checks whether this common event is a sticky one. This API uses a promise to return the result.
...@@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret ...@@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => { subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky)); console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => { }).catch((err) => {
...@@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => { ...@@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => {
## abortCommonEvent ## abortCommonEvent
```ts abortCommonEvent(callback: AsyncCallback\<void>): void
abortCommonEvent(callback: AsyncCallback<void>): void
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n ...@@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for common event aborting. // Callback for common event aborting.
function abortCB(err) { function abortCB(err) {
if (err.code) { if (err.code) {
...@@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB); ...@@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB);
## abortCommonEvent ## abortCommonEvent
```ts abortCommonEvent(): Promise\<void>
abortCommonEvent(): Promise<void>
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n ...@@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.abortCommonEvent().then(() => { subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent"); console.info("abortCommonEvent");
}).catch((err) => { }).catch((err) => {
...@@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => { ...@@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => {
## clearAbortCommonEvent ## clearAbortCommonEvent
```ts clearAbortCommonEvent(callback: AsyncCallback\<void>): void
clearAbortCommonEvent(callback: AsyncCallback<void>): void
```
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or ...@@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for clearing the aborted state of the current common event. // Callback for clearing the aborted state of the current common event.
function clearAbortCB(err) { function clearAbortCB(err) {
if (err.code) { if (err.code) {
...@@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB); ...@@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB);
## clearAbortCommonEvent ## clearAbortCommonEvent
```ts clearAbortCommonEvent(): Promise\<void>
clearAbortCommonEvent(): Promise<void>
```
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result. Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or ...@@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.clearAbortCommonEvent().then(() => { subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent"); console.info("clearAbortCommonEvent");
}).catch((err) => { }).catch((err) => {
...@@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => { ...@@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => {
## getAbortCommonEvent ## getAbortCommonEvent
```ts getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
getAbortCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect ...@@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is in the aborted state. // Callback for checking whether the current common event is in the aborted state.
function getAbortCB(err, abortEvent) { function getAbortCB(err, abortEvent) {
if (err.code) { if (err.code) {
...@@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB); ...@@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB);
## getAbortCommonEvent ## getAbortCommonEvent
```ts getAbortCommonEvent(): Promise\<boolean>
getAbortCommonEvent(): Promise<boolean>
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result. Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect ...@@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getAbortCommonEvent().then((abortEvent) => { subscriber.getAbortCommonEvent().then((abortEvent) => {
console.info("abortCommonEvent " + JSON.stringify(abortEvent)); console.info("abortCommonEvent " + JSON.stringify(abortEvent));
}).catch((err) => { }).catch((err) => {
...@@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => { ...@@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => {
## getSubscribeInfo ## getSubscribeInfo
```ts getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
```
Obtains the subscriber information. This API uses an asynchronous callback to return the result. Obtains the subscriber information. This API uses an asynchronous callback to return the result.
...@@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re ...@@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for subscriber information obtaining. // Callback for subscriber information obtaining.
function getCB(err, subscribeInfo) { function getCB(err, subscribeInfo) {
if (err.code) { if (err.code) {
...@@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB); ...@@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB);
## getSubscribeInfo ## getSubscribeInfo
```ts getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
```
Obtains the subscriber information. This API uses a promise to return the result. Obtains the subscriber information. This API uses a promise to return the result.
...@@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result ...@@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getSubscribeInfo().then((subscribeInfo) => { subscriber.getSubscribeInfo().then((subscribeInfo) => {
console.info("subscribeInfo " + JSON.stringify(subscribeInfo)); console.info("subscribeInfo " + JSON.stringify(subscribeInfo));
}).catch((err) => { }).catch((err) => {
...@@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => { ...@@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => {
## finishCommonEvent<sup>9+</sup> ## finishCommonEvent<sup>9+</sup>
```ts finishCommonEvent(callback: AsyncCallback\<void>): void
finishCommonEvent(callback: AsyncCallback<void>): void
```
Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events ...@@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing. // Callback for ordered common event finishing.
function finishCB(err) { function finishCB(err) {
if (err.code) { if (err.code) {
console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`); console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
}
} }
subscriber.finishCommonEvent(finishCB); subscriber.finishCommonEvent(finishCB);
...@@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB); ...@@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB);
## finishCommonEvent<sup>9+</sup> ## finishCommonEvent<sup>9+</sup>
```ts finishCommonEvent(): Promise\<void>
finishCommonEvent(): Promise<void\>
```
Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result. Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events ...@@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent().then(() => { subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
}).catch((err) => { }).catch((err) => {
......
...@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no ...@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | | --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | Yes | Yes | Button title. | | title | string | No | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.| | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. | | extras | { [key: string]: any } | No | No | Extra information of the button. |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | Yes | Yes | User input object. | | userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | No | No | User input object. |
...@@ -10,7 +10,7 @@ Provides the bundle information of an application. ...@@ -10,7 +10,7 @@ Provides the bundle information of an application.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Mandatory| Description | | Name | Type | Read-only| Mandatory| Description |
| ------ | ------ |---- | ------ | | ------ | ------ | ---- | ---- | ------ |
| bundle | string | Yes| Bundle information of the application.| | bundle | string | No | Yes| Bundle information of the application.|
| uid | number | No| User ID.| | uid | number | No | No| User ID.|
...@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content. ...@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ | | ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | Yes | Yes | Notification content type. | | contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | No | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. | | normal | [NotificationBasicContent](#notificationbasiccontent) | No | No | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.| | longText | [NotificationLongTextContent](#notificationlongtextcontent) | No | No | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. | | multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | No | No | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. | | picture | [NotificationPictureContent](#notificationpicturecontent) | No | No | Picture-attached. |
## NotificationBasicContent ## NotificationBasicContent
...@@ -22,11 +22,11 @@ Describes the normal text notification. ...@@ -22,11 +22,11 @@ Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | ---- | ---------------------------------- | | -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
## NotificationLongTextContent ## NotificationLongTextContent
...@@ -35,14 +35,14 @@ Describes the long text notification. ...@@ -35,14 +35,14 @@ Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | --- | -------------------------------- | | -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| longText | string | Yes | Yes | Long text of the notification. | | longText | string | No | Yes | Long text of the notification. |
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification. |
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | | expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent ## NotificationMultiLineContent
...@@ -53,12 +53,12 @@ Describes the multi-line text notification. ...@@ -53,12 +53,12 @@ Describes the multi-line text notification.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------------- | --------------- | --- | --- | -------------------------------- | | -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification.|
| longTitle | string | Yes | Yes | Title of the notification in the expanded state. | | longTitle | string | No | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. | | lines | Array\<string\> | No | Yes | Multi-line text of the notification. |
## NotificationPictureContent ## NotificationPictureContent
...@@ -69,9 +69,9 @@ Describes the picture-attached notification. ...@@ -69,9 +69,9 @@ Describes the picture-attached notification.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- | | -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | | expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. | | picture | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Yes | Picture attached to the notification. |
...@@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance. ...@@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | | ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. | | 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. | | vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. |
......
...@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request. ...@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | | --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | Yes | Yes | Notification content. | | content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | No | Yes | Notification content. |
| id | number | Yes | Yes | Notification ID. | | id | number | No | No | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. | | slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | No | Notification slot type. |
| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. | | isOngoing | boolean | No | No | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. | | isUnremovable | boolean | No | No | Whether the notification can be removed. |
| deliveryTime | number | Yes | Yes | Time when the notification is sent. | | deliveryTime | number | No | No | Time when the notification is sent. |
| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. | | tapDismissed | boolean | No | No | Whether the notification is automatically cleared. |
| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. | | autoDeletedTime | number | No | No | 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.| | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected after being clicked.|
| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. | | extraInfo | {[key: string]: any} | No | No | Extended parameters. |
| color | number | Yes | Yes | Background color of the notification. Not supported currently.| | color | number | No | No | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.| | colorEnabled | boolean | No | No | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.| | isAlertOnce | boolean | No | No | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. | | isStopwatch | boolean | No | No | Whether to display the stopwatch. |
| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. | | isCountDown | boolean | No | No | Whether to display the countdown time. |
| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. | | isFloatingIcon | boolean | No | No | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | Yes | Yes | Notification label. | | label | string | No | No | Notification label. |
| badgeIconStyle | number | Yes | Yes | Notification badge type. | | badgeIconStyle | number | No | No | Notification badge type. Not supported currently. |
| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. | | showDeliveryTime | boolean | No | No | 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. | | actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | No | No | 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.| | smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | No | 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.| | largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | No | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. | | 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. | | creatorUid<sup>8+<sup> | number | Yes | No | UID used for creating the notification. |
| creatorPid | number | Yes | No | PID 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. | | creatorUserId | number | Yes | No | ID of the user who creates the notification. |
| hashCode | string | Yes | No | Unique ID of 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. | | classification | string | No | No | 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. | | groupName<sup>8+<sup> | string | No | No | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. | | template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | No | 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. | | 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. | | 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. | | distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | No | No | 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. | | 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. | | notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#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. | | removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **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. | | badgeNumber<sup>9+<sup> | number | No | No | Number of notifications displayed on the application icon. |
## DistributedOptions ## DistributedOptions
...@@ -55,9 +55,9 @@ Describes distributed notification options. ...@@ -55,9 +55,9 @@ Describes distributed notification options.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed<sup>8+<sup> | boolean | Yes | Yes | Whether the notification is a distributed notification. | | isDistributed<sup>8+<sup> | boolean | No | No | 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. | | supportDisplayDevices<sup>8+<sup> | Array\<string> | No | No | 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. | | supportOperateDevices<sup>8+<sup> | Array\<string> | No | No | 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. | | 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. |
...@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot. ...@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | | -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. | | type | [SlotType](js-apis-notificationManager.md#slottype) | No | 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.| | level | number | No | No | 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. | | desc | string | No | No | Notification slot description. |
| badgeFlag | boolean | Yes | Yes | Whether to display the badge. | | badgeFlag | boolean | No | No | Whether to display the badge. |
| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. | | bypassDnd | boolean | No | No | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. | | lockscreenVisibility | number | No | No | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | Yes | Yes | Whether to enable vibration for the notification. | | vibrationEnabled | boolean | No | No | Whether to enable vibration for the notification. |
| sound | string | Yes | Yes | Notification alert tone. | | sound | string | No | No | Notification alert tone. |
| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. | | lightEnabled | boolean | No | No | Whether the indicator blinks for the notification. |
| lightColor | number | Yes | Yes | Indicator color of the notification. | | lightColor | number | No | No | Indicator color of the notification. |
| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. | | vibrationValues | Array\<number\> | No | No | Vibration mode of the notification. |
| enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. | | enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. |
# NotificationSorting
Provides sorting information of active notifications.
> **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
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 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 | Description of the notification slot. |
# NotificationSortingMap
Provides sorting information of active notifications in all subscribed notifications.
> **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
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| sortings | { [key: string]: [NotificationSorting](js-apis-inner-notification-notificationSorting.md) } | Yes | Yes | Array of notification sorting information.|
| sortedHashCode | Array\<string> | Yes | Yes | Hash codes for notification sorting.|
# NotificationSubscribeInfo
Provides the information about the publisher for notification subscription.
> **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
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| bundleNames | Array\<string> | No | No | Bundle names of the applications whose notifications are to be subscribed to. |
| userId | number | No | No | User ID. |
# NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](js-apis-notificationSubscribe.md).
> **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.
## Modules to Import
```js
import notificationSubscribe from '@ohos.notificationSubscribe';
```
**System API**: This is a system API and cannot be called by third-party applications.
### onConsume
onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a new notification is received.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification received.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConsumeCallback(data) {
console.info('===> onConsume in test');
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
};
let subscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onCancel
onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a notification is canceled.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification to cancel.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onCancelCallback(data) {
console.info('===> onCancel in test');
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
}
let subscriber = {
onCancel: onCancelCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onUpdate
onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
Called when notification sorting is updated.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap) | Yes| Latest notification sorting list.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
let subscriber = {
onUpdate: onUpdateCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onConnect
onConnect?:() => void
Called when the subscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
let subscriber = {
onConnect: onConnectCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDisconnect
onDisconnect?:() => void
Called when unsubscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function unsubscribeCallback(err) {
if (err.code) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// The onConnect callback is invoked when subscription to the notification is complete.
notificationSubscribe.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
### onDestroy
onDestroy?:() => void
Called when the service is disconnected.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDestroyCallback() {
console.info('===> onDestroy in test');
}
let subscriber = {
onDestroy: onDestroyCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDoNotDisturbDateChange<sup>8+</sup>
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void
Called when the DND time settings are changed.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | notification.[DoNotDisturbDate](js-apis-notificationManager.md#DoNotDisturbDate) | Yes| DND time setting updates.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onEnabledNotificationChanged<sup>8+</sup>
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)) => void
Listens for the notification enabled status changes.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable);
};
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onBadgeChanged<sup>10+</sup>
onBadgeChanged?:(data: [BadgeNumberCallbackData](#badgenumbercallbackdata10)) => void
Listens for the change of the notification badge number.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[BadgeNumberCallbackData](#badgenumbercallbackdata10)\> | Yes | Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onBadgeChangedCallback(data) {
console.info("bundle: ", data.bundle);
console.info("uid: ", data.uid);
console.info("badgeNumber: ", data.badgeNumber);
};
let subscriber = {
onBadgeChanged: onBadgeChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
## SubscribeCallbackData
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request | [NotificationRequest](js-apis-inner-notification-notificationRequest#notificationrequest) | Yes | Yes | Notification content.|
| sortingMap | [NotificationSortingMap](js-apis-inner-notification-notificationSortingMap.md) | 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.|
## EnabledNotificationCallbackData<sup>8+</sup>
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| ------ | ------- | ---- | --- | ---------------- |
| bundle | string | Yes | Yes | Bundle name of the application. |
| uid | number | Yes | Yes | UID of the application. |
| enable | boolean | Yes | Yes | Notification enabled status of the application.|
## BadgeNumberCallbackData<sup>10+</sup>
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| ----------- | ------ | ---- | ---- | ------------ |
| bundle | string | Yes | Yes | Bundle name of the application.|
| uid | number | Yes | Yes | UID of the application. |
| badgeNumber | number | Yes | Yes | Number of notifications displayed on the application icon. |
...@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template. ...@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description | | Name| Type | Read-only| Mandatory| Description |
| ---- | ---------------------- | ---- | ---- | ---------- | | ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.| | name | string | No | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.| | data | {[key:string]: Object} | No | Yes | Template data.|
...@@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input. ...@@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------- | ------ | --- | ---- | ----------------------------- | | -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.| | inputKey | string | No | Yes | Key to identify the user input.|
...@@ -566,7 +566,7 @@ Notification.getSlot(slotType).then((data) => { ...@@ -566,7 +566,7 @@ Notification.getSlot(slotType).then((data) => {
## Notification.getSlots ## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains all notification slots. This API uses an asynchronous callback to return the result. Obtains all notification slots. This API uses an asynchronous callback to return the result.
...@@ -576,7 +576,7 @@ Obtains all notification slots. This API uses an asynchronous callback to return ...@@ -576,7 +576,7 @@ Obtains all notification slots. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | -------------------- | | -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -726,7 +726,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -726,7 +726,7 @@ 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-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber. |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes | Notification subscription information.| | info | [NotificationSubscribeInfo](#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.|
...@@ -769,7 +769,7 @@ Subscribes to notifications of all applications under this user. This API uses a ...@@ -769,7 +769,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-inner-notification-notificationSubscriber.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.|
**Example** **Example**
...@@ -807,7 +807,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -807,7 +807,7 @@ 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-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber.|
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No | Notification subscription information. | | info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No | Notification subscription information. |
**Example** **Example**
...@@ -840,7 +840,7 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu ...@@ -840,7 +840,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-inner-notification-notificationSubscriber.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.|
**Example** **Example**
...@@ -878,7 +878,7 @@ Unsubscribes from a notification. This API uses a promise to return the result. ...@@ -878,7 +878,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-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber.|
**Example** **Example**
...@@ -910,7 +910,7 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -910,7 +910,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 information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information 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.|
...@@ -946,7 +946,7 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -946,7 +946,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 information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
| enable | boolean | Yes | Whether to enable notification. | | enable | boolean | Yes | Whether to enable notification. |
**Example** **Example**
...@@ -976,7 +976,7 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -976,7 +976,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 information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | 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.|
**Example** **Example**
...@@ -1011,7 +1011,7 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1011,7 +1011,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 information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
**Return value** **Return value**
...@@ -1078,7 +1078,7 @@ Checks whether notification is enabled for this application. This API uses a pro ...@@ -1078,7 +1078,7 @@ Checks whether notification is enabled for this application. This API uses a pro
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
**Return value** **Return value**
...@@ -1110,7 +1110,7 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1110,7 +1110,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 information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information 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.|
...@@ -1146,7 +1146,7 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1146,7 +1146,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 information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
| enable | boolean | Yes | Whether to enable notification. | | enable | boolean | Yes | Whether to enable notification. |
**Example** **Example**
...@@ -1176,7 +1176,7 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1176,7 +1176,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 information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | 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.|
**Example** **Example**
...@@ -1211,7 +1211,7 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1211,7 +1211,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 information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
**Return value** **Return value**
...@@ -1246,7 +1246,7 @@ Sets the notification slot for a specified application. This API uses an asynchr ...@@ -1246,7 +1246,7 @@ 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 information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. |
| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot. | | slot | [NotificationSlot](#notificationslot) | Yes | Notification slot. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -1285,7 +1285,7 @@ Sets the notification slot for a specified application. This API uses a promise ...@@ -1285,7 +1285,7 @@ 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 information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot.| | slot | [NotificationSlot](#notificationslot) | Yes | Notification slot.|
**Example** **Example**
...@@ -1304,7 +1304,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1304,7 +1304,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
...@@ -1318,8 +1318,8 @@ Obtains the notification slots of a specified application. This API uses an asyn ...@@ -1318,8 +1318,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 information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1339,7 +1339,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ...@@ -1339,7 +1339,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
Obtains the notification slots of a specified application. This API uses a promise to return the result. Obtains the notification slots of a specified application. This API uses a promise to return the result.
...@@ -1353,13 +1353,13 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1353,13 +1353,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 information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.| | Promise\<Array\<[NotificationSlot](#notificationslot)>> | Promise used to return the result.|
**Example** **Example**
...@@ -1388,7 +1388,7 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1388,7 +1388,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 information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. |
| callback | AsyncCallback\<number\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<number\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1423,7 +1423,7 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1423,7 +1423,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 information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
**Return value** **Return value**
...@@ -1458,9 +1458,9 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1458,9 +1458,9 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ----------------------------------| ---- | -------------------- | | --------------- | ----------------------------------| ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. |
| notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | | notificationKey | [NotificationKey](#notificationkeydeprecated) | Yes | Notification key. |
| reason | [RemoveReason](#removereason9) | Yes | Indicates the reason for deleting a notification. | | reason | [RemoveReason](#removereason9-deprecated) | Yes | Indicates the reason for deleting a notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1500,9 +1500,9 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1500,9 +1500,9 @@ Removes a notification for a specified bundle. This API uses a promise to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | --------------- | ---- | ---------- | | --------------- | --------------- | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.|
| notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | | notificationKey | [NotificationKey](#notificationkeydeprecated) | Yes | Notification key. |
| reason | [RemoveReason](#removereason9) | Yes | Reason for deleting the notification. | | reason | [RemoveReason](#removereason9-deprecated) | Yes | Reason for deleting the notification. |
**Example** **Example**
...@@ -1536,8 +1536,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1536,8 +1536,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
| 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 **hashCode** in the [NotificationRequest](#notificationrequest) object of [SubscribeCallbackData](#subscribecallbackdata) of the [onConsume](js-apis-inner-notification-notificationSubscriber.md#onconsume) callback. |
| reason | [RemoveReason](#removereason9) | Yes | Indicates the reason for deleting a notification. | | reason | [RemoveReason](#removereason9-deprecated) | Yes | Indicates the reason for deleting a notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1573,7 +1573,7 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1573,7 +1573,7 @@ Removes a notification for a specified bundle. This API uses a promise to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------- | ---- | ---------- | | -------- | ---------- | ---- | ---------- |
| hashCode | string | Yes | Unique notification ID.| | hashCode | string | Yes | Unique notification ID.|
| reason | [RemoveReason](#removereason9) | Yes | Reason for deleting the notification. | | reason | [RemoveReason](#removereason9-deprecated) | Yes | Reason for deleting the notification. |
**Example** **Example**
...@@ -1601,7 +1601,7 @@ Removes all notifications for a specified application. This API uses an asynchro ...@@ -1601,7 +1601,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](#bundleoptiondeprecated) | 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.|
**Example** **Example**
...@@ -1668,7 +1668,7 @@ Removes all notifications for a specified application. This API uses a promise t ...@@ -1668,7 +1668,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](#bundleoptiondeprecated) | No | Bundle information of the application.|
**Example** **Example**
...@@ -1743,7 +1743,7 @@ Notification.removeAll(userId).then(() => { ...@@ -1743,7 +1743,7 @@ Notification.removeAll(userId).then(() => {
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains all active notifications. This API uses an asynchronous callback to return the result. Obtains all active notifications. This API uses an asynchronous callback to return the result.
...@@ -1757,7 +1757,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu ...@@ -1757,7 +1757,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](#notificationrequest)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1775,7 +1775,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ...@@ -1775,7 +1775,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#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.
...@@ -1789,7 +1789,7 @@ Obtains all active notifications. This API uses a promise to return the result. ...@@ -1789,7 +1789,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](#notificationrequest)>> | Promise used to return the result.|
**Example** **Example**
...@@ -1969,7 +1969,7 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -1969,7 +1969,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](#bundleoptiondeprecated) | 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.|
...@@ -2006,7 +2006,7 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -2006,7 +2006,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](#bundleoptiondeprecated) | Yes | Bundle information of the application. |
| groupName | string | Yes | Name of the notification group.| | groupName | string | Yes | Name of the notification group.|
**Example** **Example**
...@@ -2035,7 +2035,7 @@ Sets the DND time. This API uses an asynchronous callback to return the result. ...@@ -2035,7 +2035,7 @@ Sets the DND time. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------- | | -------- | --------------------- | ---- | ---------------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set. | | date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -2074,7 +2074,7 @@ Sets the DND time. This API uses a promise to return the result. ...@@ -2074,7 +2074,7 @@ Sets the DND time. This API uses a promise to return the result.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ---- | ---------------- | ---- | -------------- | | ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set.| | date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set.|
**Example** **Example**
...@@ -2106,7 +2106,7 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t ...@@ -2106,7 +2106,7 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------- | | -------- | --------------------- | ---- | ---------------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set. | | date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set. |
| userId | number | Yes | ID of the user for whom you want to set the DND time.| | userId | number | Yes | ID of the user for whom you want to set the DND time.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -2147,7 +2147,7 @@ Sets the DND time for a specified user. This API uses a promise to return the re ...@@ -2147,7 +2147,7 @@ Sets the DND time for a specified user. This API uses a promise to return the re
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ---------------- | ---- | -------------- | | ------ | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set.| | date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set.|
| userId | number | Yes | ID of the user for whom you want to set the DND time.| | userId | number | Yes | ID of the user for whom you want to set the DND time.|
**Example** **Example**
...@@ -2183,7 +2183,7 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul ...@@ -2183,7 +2183,7 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | ---------------------- | | -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -2215,7 +2215,7 @@ Obtains the DND time. This API uses a promise to return the result. ...@@ -2215,7 +2215,7 @@ Obtains the DND time. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ------------------------------------------------- | ----------------------------------------- | | ------------------------------------------------- | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.| | Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.|
**Example** **Example**
...@@ -2242,7 +2242,7 @@ Obtains the DND time of a specified user. This API uses an asynchronous callback ...@@ -2242,7 +2242,7 @@ Obtains the DND time of a specified user. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | ---------------------- | | -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Yes | Callback used to return the result.|
| userId | number | Yes | User ID.| | userId | number | Yes | User ID.|
**Example** **Example**
...@@ -2283,7 +2283,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the ...@@ -2283,7 +2283,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the
| Type | Description | | Type | Description |
| ------------------------------------------------- | ----------------------------------------- | | ------------------------------------------------- | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.| | Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.|
**Example** **Example**
...@@ -2589,7 +2589,7 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2589,7 +2589,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](#bundleoptiondeprecated) | Yes | Bundle information of the application. |
| enable | boolean | Yes | Whether the device supports distributed notifications. | | enable | boolean | Yes | Whether the device supports distributed notifications. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -2629,7 +2629,7 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2629,7 +2629,7 @@ Sets whether a specified application supports distributed notifications. This AP
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Application bundle. |
| enable | boolean | Yes | Whether the device supports distributed notifications. | | enable | boolean | Yes | Whether the device supports distributed notifications. |
**Example** **Example**
...@@ -2661,7 +2661,7 @@ Obtains whether an application supports distributed notifications based on the b ...@@ -2661,7 +2661,7 @@ Obtains whether an application supports distributed notifications based on the b
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Application bundle. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -2698,7 +2698,7 @@ Checks whether a specified application supports distributed notifications. This ...@@ -2698,7 +2698,7 @@ Checks whether a specified application supports distributed notifications. This
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | | bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Application bundle. |
**Return value** **Return value**
...@@ -2735,7 +2735,7 @@ Obtains the notification reminder type. This API uses an asynchronous callback t ...@@ -2735,7 +2735,7 @@ Obtains the notification reminder type. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | -------------------------- | | -------- | --------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8-deprecated)\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -2767,7 +2767,7 @@ Obtains the notification reminder type. This API uses a promise to return the re ...@@ -2767,7 +2767,7 @@ Obtains the notification reminder type. This API uses a promise to return the re
| Type | Description | | Type | Description |
| ------------------ | --------------- | | ------------------ | --------------- |
| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise used to return the result.| | Promise\<[DeviceRemindType](#deviceremindtype8-deprecated)\> | Promise used to return the result.|
**Example** **Example**
...@@ -2777,1033 +2777,255 @@ Notification.getDeviceRemindType().then((data) => { ...@@ -2777,1033 +2777,255 @@ Notification.getDeviceRemindType().then((data) => {
}); });
``` ```
## SubscribeCallbackData
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Publishes an agent-powered notification. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**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.
**Parameters** | Name | Type | Readable| Writable| Description |
| --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request | [NotificationRequest](#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.|
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request | [NotificationRequest](#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. |
| userId | number | Yes | User ID. |
| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example** ## EnabledNotificationCallbackData<sup>8+</sup>
```js **System capability**: SystemCapability.Notification.Notification
// publishAsBundle callback
function callback(err) {
if (err.code) {
console.info("publishAsBundle failed " + JSON.stringify(err));
} else {
console.info("publishAsBundle success");
}
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo";
// User ID
let userId = 100;
// NotificationRequest object
let request = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId, callback); **System API**: This is a system API and cannot be called by third-party applications.
```
## Notification.publishAsBundle<sup>9+</sup> | Name | Type | Readable| Writable| Description |
| ------ | ------- | ---- | --- | ---------------- |
| 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.|
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
Publishes a notification through the reminder agent. This API uses a promise to return the result. ## DoNotDisturbDate<sup>8+</sup> <sup>deprecated</sup>
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER > **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate) instead.
**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.
**Parameters** | Name | Type | Readable| Writable| Description |
| ----- | -------------------------------------- | ---- | ---- | ---------------------- |
| type | [DoNotDisturbType](#donotdisturbtype8-deprecated) | Yes | Yes | DND time type.|
| begin | Date | Yes | Yes | DND start time.|
| end | Date | Yes | Yes | DND end time.|
| Name | Type | Mandatory| Description | ## DoNotDisturbType<sup>8+</sup> <sup>deprecated</sup>
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#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. |
| userId | number | Yes | User ID. |
**Example** **System capability**: SystemCapability.Notification.Notification
```js > **NOTE**
// Bundle name of the application whose notification function is taken over by the reminder agent >
let representativeBundle = "com.example.demo"; > This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DoNotDisturbType](js-apis-notificationManager.md#donotdisturbtype) instead.
// User ID
let userId = 100;
// NotificationRequest object
let request = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId).then(() => { **System API**: This is a system API and cannot be called by third-party applications.
console.info("publishAsBundle success");
});
```
## Notification.cancelAsBundle<sup>9+</sup> | Name | Value | Description |
| ------------ | ---------------- | ------------------------------------------ |
| TYPE_NONE | 0 | Non-DND. |
| TYPE_ONCE | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
| TYPE_DAILY | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute). |
cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result. ## ContentType
**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. | Name | Value | Description |
| --------------------------------- | ----------- | ------------------ |
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER | NOTIFICATION_CONTENT_BASIC_TEXT | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification. |
| NOTIFICATION_CONTENT_LONG_TEXT | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification. |
| NOTIFICATION_CONTENT_PICTURE | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification. |
| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification. |
| NOTIFICATION_CONTENT_MULTILINE | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|
**System API**: This is a system API and cannot be called by third-party applications. ## SlotLevel
**Parameters** **System capability**: SystemCapability.Notification.Notification
| Name | Type | Mandatory| Description | | Name | Value | Description |
| -------------------- | ------------- | ---- | ------------------------ | | --------------------------------- | ----------- | ------------------ |
| id | number | Yes | Notification ID. | | LEVEL_NONE | 0 | The notification function is disabled. |
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | | LEVEL_MIN | 1 | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
| userId | number | Yes | User ID. | | LEVEL_LOW | 2 | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
| callback | AsyncCallback | Yes | Callback used to return the result.| | LEVEL_DEFAULT | 3 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.|
| LEVEL_HIGH | 4 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.|
**Example**
```js ## BundleOption<sup>deprecated</sup>
// cancelAsBundle
function cancelAsBundleCallback(err) {
if (err.code) {
console.info("cancelAsBundle failed " + JSON.stringify(err));
} else {
console.info("cancelAsBundle success");
}
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo";
// User ID
let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); **System capability**: SystemCapability.Notification.Notification
```
## Notification.cancelAsBundle<sup>9+</sup> > **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [notificationManager.BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) instead.
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\> | Name | Type | Read-only| Mandatory| Description |
| ------ | ------ |---- | --- | ------ |
| bundle | string | No | Yes | Bundle information of the application.|
| uid | number | No | No | User ID.|
Cancels a notification published by the reminder agent. This API uses a promise to return the result. ## NotificationKey<sup>deprecated</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. > **NOTE**
>
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [notificationManager.NotificationKey](js-apis-notificationSubscribe.md#notificationkey) instead.
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** | Name | Type | Readable| Writable| Description |
| ----- | ------ | ---- | --- | -------- |
| id | number | Yes | Yes | Notification ID. |
| label | string | Yes | Yes | Notification label.|
| Name | Type | Mandatory| Description |
| -------------------- | ------ | ---- | ------------------ |
| id | number | Yes | Notification ID. |
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent.|
| userId | number | Yes | User ID.|
**Example** ## SlotType
```js **System capability**: SystemCapability.Notification.Notification
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo";
// User ID
let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { | Name | Value | Description |
console.info("cancelAsBundle success"); | -------------------- | -------- | ---------- |
}); | UNKNOWN_TYPE | 0 | Unknown type.|
``` | SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.|
| SERVICE_INFORMATION | 2 | Notification slot for service information.|
| CONTENT_INFORMATION | 3 | Notification slot for content consultation.|
| OTHER_TYPES | 0xFFFF | Notification slot for other purposes.|
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void ## NotificationActionButton
Sets the enabled status of a notification slot type for a specified application. This API uses an asynchronous callback to return the result. Describes the button displayed in the notification.
**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. | Name | Type | Readable| Writable| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER | 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](#notificationuserinput8) | Yes | Yes | User input object. |
**Parameters**
| Name | Type | Mandatory| Description | ## NotificationBasicContent
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| enable | boolean | Yes | Whether to enable notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example** Describes the normal text notification.
```js **System capability**: SystemCapability.Notification.Notification
// enableNotificationSlot
function enableSlotCallback(err) {
if (err.code) {
console.info("enableNotificationSlot failed " + JSON.stringify(err));
} else {
console.info("enableNotificationSlot success");
}
};
Notification.enableNotificationSlot( | Name | Type | Readable| Writable| Description |
{ bundle: "ohos.samples.notification", }, | -------------- | ------ | ---- | ---- | ---------------------------------- |
Notification.SlotType.SOCIAL_COMMUNICATION, | title | string | Yes | Yes | Notification title. |
true, | text | string | Yes | Yes | Notification content. |
enableSlotCallback); | additionalText | string | Yes | Yes | Additional information of the notification.|
```
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> ## NotificationLongTextContent
Sets the enabled status of a notification slot type for a specified application. This API uses a promise to return the result. Describes the long text notification.
**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. | 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. |
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters** ## NotificationMultiLineContent
| Name| Type | Mandatory| Description | Describes the multi-line text notification.
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
| enable | boolean | Yes | Whether to enable notification. |
**Example** **System capability**: SystemCapability.Notification.Notification
```js | Name | Type | Readable| Writable| Description |
// enableNotificationSlot | -------------- | --------------- | --- | --- | -------------------------------- |
Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", }, | title | string | Yes | Yes | Notification title. |
Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => { | text | string | Yes | Yes | Notification content. |
console.info("enableNotificationSlot success"); | 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. |
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void ## NotificationPictureContent
Checks whether a specified notification slot type is enabled for a specified application. This API uses an asynchronous callback to return the result. Describes the picture-attached notification.
**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. | Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- |
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER | 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. |
**Parameters**
| Name | Type | Mandatory| Description | ## NotificationContent
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example** Describes the notification content.
```js **System capability**: SystemCapability.Notification.Notification
// isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
if (err.code) {
console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
} else {
console.info("isNotificationSlotEnabled success");
}
};
Notification.isNotificationSlotEnabled( | Name | Type | Readable| Writable| Description |
{ bundle: "ohos.samples.notification", }, | ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
Notification.SlotType.SOCIAL_COMMUNICATION, | contentType | [ContentType](#contenttype) | Yes | Yes | Notification content type. |
getEnableSlotCallback); | 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. |
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\> ## NotificationFlagStatus<sup>8+</sup>
Checks whether a specified notification slot type is enabled for a specified application. This API uses a promise to return the result. Describes the notification flag status.
**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.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER | Name | Value | Description |
| -------------- | --- | --------------------------------- |
**Parameters** | TYPE_NONE | 0 | The default flag is used. |
| TYPE_OPEN | 1 | The notification flag is enabled. |
| Name| Type | Mandatory| Description | | TYPE_CLOSE | 2 | The notification flag is disabled. |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
**Return value**
| Type | Description |
| ------------------ | ------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
**Example**
```js
// isNotificationSlotEnabled
Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
```
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void ## NotificationFlags<sup>8+</sup>
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses an asynchronous callback to return the result. Enumerates notification flags.
**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. | Name | Type | Readable| Writable| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes | No | Whether to enable vibration for the notification. |
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters** ## NotificationRequest
| Name| Type | Mandatory| Description | Describes the notification request.
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| enable | boolean | Yes | Whether the feature is enabled. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example** **System capability**: SystemCapability.Notification.Notification
```js
let userId = 100;
let enable = true;
function callback(err) {
if (err.code) {
console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
} else {
console.info("setSyncNotificationEnabledWithoutApp success");
}
}
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
```
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| enable | boolean | Yes | Whether the feature is enabled. |
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let userId = 100;
let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => {
console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
});
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example**
```js
let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(err, data) {
if (err) {
console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
} else {
console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
}
}
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
**Return value**
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
**Example**
```js
let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
});
```
## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).
**System API**: This is a system API and cannot be called by third-party applications.
### onConsume
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
Callback for receiving notifications.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification received.|
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function onConsumeCallback(data) {
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
};
let subscriber = {
onConsume: onConsumeCallback
};
Notification.subscribe(subscriber, subscribeCallback);
```
### onCancel
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
Callback for canceling notifications.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification to cancel.|
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function onCancelCallback(data) {
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
}
let subscriber = {
onCancel: onCancelCallback
};
Notification.subscribe(subscriber, subscribeCallback);
```
### onUpdate
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
Callback for notification sorting updates.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Latest notification sorting list.|
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
let subscriber = {
onUpdate: onUpdateCallback
};
Notification.subscribe(subscriber, subscribeCallback);
```
### onConnect
onConnect?:() => void
Callback for subscription.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
let subscriber = {
onConnect: onConnectCallback
};
Notification.subscribe(subscriber, subscribeCallback);
```
### onDisconnect
onDisconnect?:() => void
Callback for unsubscription.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function unsubscribeCallback(err) {
if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err));
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// The onConnect callback is invoked when subscription to the notification is complete.
Notification.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
Notification.unsubscribe(subscriber, unsubscribeCallback);
```
### onDestroy
onDestroy?:() => void
Callback for service disconnection.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function onDestroyCallback() {
console.info('===> onDestroy in test');
}
let subscriber = {
onDestroy: onDestroyCallback
};
Notification.subscribe(subscriber, subscribeCallback);
```
### onDoNotDisturbDateChange<sup>8+</sup>
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
Callback for DND time setting updates.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
Notification.subscribe(subscriber, subscribeCallback);
let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(),
end: new Date(2021, 11, 15, 18, 0)
}
// Set the onDoNotDisturbDateChange callback for DND time setting updates.
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("setDoNotDisturbDate sucess");
});
```
### onEnabledNotificationChanged<sup>8+</sup>
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) => void
Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribeCallback");
}
};
function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: " + callbackData.bundle);
console.info("uid: " + callbackData.uid);
console.info("enable: " + callbackData.enable);
};
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
Notification.subscribe(subscriber, subscribeCallback);
let bundle = {
bundle: "bundleName1",
}
// Set the onEnabledNotificationChanged callback that is triggered when the notification enabled status changes.
Notification.enableNotification(bundle, false).then(() => {
console.info("enableNotification sucess");
});
```
## 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](#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.|
## EnabledNotificationCallbackData<sup>8+</sup>
**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 |
| ------ | ------- | ---- | --- | ---------------- |
| 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.|
## DoNotDisturbDate<sup>8+</sup>
**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 |
| ----- | -------------------------------------- | ---- | ---- | ---------------------- |
| type | [DoNotDisturbType](#donotdisturbtype8) | Yes | Yes | DND time type.|
| begin | Date | Yes | Yes | DND start time.|
| end | Date | Yes | Yes | DND end time.|
## DoNotDisturbType<sup>8+</sup>
**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 | Non-DND. |
| TYPE_ONCE | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
| TYPE_DAILY | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute). |
## ContentType
**System capability**: SystemCapability.Notification.Notification
| Name | Value | Description |
| --------------------------------- | ----------- | ------------------ |
| NOTIFICATION_CONTENT_BASIC_TEXT | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification. |
| NOTIFICATION_CONTENT_LONG_TEXT | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification. |
| NOTIFICATION_CONTENT_PICTURE | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification. |
| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification. |
| NOTIFICATION_CONTENT_MULTILINE | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|
## SlotLevel
**System capability**: SystemCapability.Notification.Notification
| Name | Value | Description |
| --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE | 0 | The notification function is disabled. |
| LEVEL_MIN | 1 | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
| LEVEL_LOW | 2 | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
| LEVEL_DEFAULT | 3 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.|
| LEVEL_HIGH | 4 | The notification feature 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.|
## NotificationKey
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ----- | ------ | ---- | --- | -------- |
| id | number | Yes | Yes | Notification ID. |
| label | string | Yes | Yes | Notification label.|
## SlotType
**System capability**: SystemCapability.Notification.Notification
| Name | Value | Description |
| -------------------- | -------- | ---------- |
| UNKNOWN_TYPE | 0 | Unknown type.|
| SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.|
| SERVICE_INFORMATION | 2 | Notification slot for service information.|
| CONTENT_INFORMATION | 3 | Notification slot for content consultation.|
| 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<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | 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
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. |
## 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<sup>8+</sup>
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<sup>8+</sup>
Enumerates notification flags.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes | No | Whether to enable vibration for the notification. |
## NotificationRequest
Describes the notification request.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | | --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
...@@ -3947,12 +3169,16 @@ Provides the notification user input. ...@@ -3947,12 +3169,16 @@ Provides the notification user input.
| inputKey | string | Yes | Yes | Key to identify the user input.| | inputKey | string | Yes | Yes | Key to identify the user input.|
## DeviceRemindType<sup>8+</sup> ## DeviceRemindType<sup>8+</sup> <sup>deprecated</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.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DeviceRemindType](js-apis-notificationManager.md#deviceremindtype) instead.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | --- | --------------------------------- | | -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. | | IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. |
...@@ -3961,25 +3187,33 @@ Provides the notification user input. ...@@ -3961,25 +3187,33 @@ Provides the notification user input.
| ACTIVE_REMIND | 3 | The device is in use. | | ACTIVE_REMIND | 3 | The device is in use. |
## SourceType<sup>8+</sup> ## SourceType<sup>8+</sup> <sup>deprecated</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.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.SourceType](js-apis-notificationManager.md#sourcetype) instead.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| TYPE_NORMAL | 0 | Normal notification. | | TYPE_NORMAL | 0 | Normal notification. |
| TYPE_CONTINUOUS | 1 | Continuous notification. | | TYPE_CONTINUOUS | 1 | Continuous notification. |
| TYPE_TIMER | 2 | Timed notification. | | TYPE_TIMER | 2 | Timed notification. |
## RemoveReason<sup>9+</sup> ## RemoveReason<sup>9+</sup> <sup>deprecated</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.
> **NOTE**
>
> This API is supported since API version 9 and deprecated since API version 9. You are advised to use [notificationManager.RemoveReason](js-apis-notificationSubscribe.md#removereason) instead.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | | CLICK_REASON_REMOVE<sup>9+</sup> | 1 | The notification is removed after a click on it. |
| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | | CANCEL_REASON_REMOVE<sup>9+</sup> | 2 | The notification is removed by the user. |
...@@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -88,8 +87,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -88,8 +87,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -209,8 +204,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -209,8 +204,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -265,7 +258,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -265,7 +258,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -341,7 +332,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -341,7 +332,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -375,7 +365,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -375,7 +365,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -414,7 +403,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -414,7 +403,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -452,9 +440,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -452,9 +440,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -502,9 +487,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -502,9 +487,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -543,7 +525,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -543,7 +525,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -583,7 +564,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -583,7 +564,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -622,9 +602,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -622,9 +602,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -676,9 +653,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -676,9 +653,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -721,7 +695,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -721,7 +695,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -767,7 +740,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -767,7 +740,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -783,7 +755,7 @@ notificationManager.getSlot(slotType).then((data) => { ...@@ -783,7 +755,7 @@ notificationManager.getSlot(slotType).then((data) => {
## notificationManager.getSlots ## notificationManager.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains all notification slots of this application. This API uses an asynchronous callback to return the result. Obtains all notification slots of this application. This API uses an asynchronous callback to return the result.
...@@ -801,7 +773,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -801,7 +773,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -822,7 +793,7 @@ notificationManager.getSlots(getSlotsCallback); ...@@ -822,7 +793,7 @@ notificationManager.getSlots(getSlotsCallback);
## notificationManager.getSlots ## notificationManager.getSlots
getSlots(): Promise\<Array\<NotificationSlot\>> getSlots(): Promise\<Array\<NotificationSlot>>
Obtains all notification slots of this application. This API uses a promise to return the result. Obtains all notification slots of this application. This API uses a promise to return the result.
...@@ -840,7 +811,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -840,7 +811,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -874,7 +844,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -874,7 +844,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -914,7 +883,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -914,7 +883,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -948,7 +916,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -948,7 +916,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -980,7 +947,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -980,7 +947,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1019,9 +985,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1019,9 +985,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1068,9 +1031,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1068,9 +1031,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1104,7 +1064,7 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1104,7 +1064,7 @@ Checks whether notification is enabled for a specified application. This API use
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#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\<boolean\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1112,9 +1072,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1112,9 +1072,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1166,9 +1123,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1166,9 +1123,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1201,7 +1155,7 @@ Checks whether notification is enabled for this application. This API uses an as ...@@ -1201,7 +1155,7 @@ Checks whether notification is enabled for this application. This API uses an as
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -1209,9 +1163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1209,9 +1163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1242,11 +1193,93 @@ Checks whether notification is enabled for the current application. This API use ...@@ -1242,11 +1193,93 @@ Checks whether notification is enabled for the current application. This API use
**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.
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**Example**
```ts
notificationManager.isNotificationEnabled().then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
Checks whether notification is enabled for a specified user. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ |
| userId | number | Yes | User ID.|
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
| 1600008 | The user is not exist. |
**Example**
```ts
function isNotificationEnabledCallback(err, data) {
if (err) {
console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("isNotificationEnabled success");
}
}
let userId = 1;
notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number): Promise\<boolean\>
Checks whether notification is enabled for a specified user. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.| | userId | number | Yes | User ID.|
**Return value** **Return value**
...@@ -1260,18 +1293,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1260,18 +1293,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 17700001 | The specified bundle name was not found. | | 1600008 | The user is not exist.. |
**Example** **Example**
```ts ```ts
notificationManager.isNotificationEnabled().then((data) => { let userId = 1;
notificationManager.isNotificationEnabled(userId).then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1302,9 +1334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1302,9 +1334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1351,9 +1380,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1351,9 +1380,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1395,9 +1421,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1395,9 +1421,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1449,9 +1472,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1449,9 +1472,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1486,7 +1506,6 @@ Sets the notification badge number. This API uses a promise to return the result ...@@ -1486,7 +1506,6 @@ Sets the notification badge number. This API uses a promise to return the result
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1522,7 +1541,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1522,7 +1541,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1569,9 +1587,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1569,9 +1587,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1621,9 +1636,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1621,9 +1636,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1645,7 +1657,7 @@ notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1645,7 +1657,7 @@ notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => {
## notificationManager.getSlotsByBundle ## notificationManager.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
...@@ -1660,7 +1672,7 @@ Obtains the notification slots of a specified application. This API uses an asyn ...@@ -1660,7 +1672,7 @@ Obtains the notification slots of a specified application. This API uses an asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. |
| callback | AsyncCallback<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | 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**
...@@ -1668,9 +1680,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1668,9 +1680,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1694,7 +1703,7 @@ notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback); ...@@ -1694,7 +1703,7 @@ notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback);
## notificationManager.getSlotsByBundle ## notificationManager.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
Obtains the notification slots of a specified application. This API uses a promise to return the result. Obtains the notification slots of a specified application. This API uses a promise to return the result.
...@@ -1714,7 +1723,7 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1714,7 +1723,7 @@ Obtains the notification slots of a specified application. This API uses a promi
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | 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**
...@@ -1722,9 +1731,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1722,9 +1731,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1766,9 +1772,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1766,9 +1772,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1820,9 +1823,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1820,9 +1823,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1842,7 +1842,7 @@ notificationManager.getSlotNumByBundle(bundle).then((data) => { ...@@ -1842,7 +1842,7 @@ notificationManager.getSlotNumByBundle(bundle).then((data) => {
## notificationManager.getAllActiveNotifications ## notificationManager.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains all active notifications. This API uses an asynchronous callback to return the result. Obtains all active notifications. This API uses an asynchronous callback to return the result.
...@@ -1856,15 +1856,12 @@ Obtains all active notifications. This API uses an asynchronous callback to retu ...@@ -1856,15 +1856,12 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#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**
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1907,9 +1904,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1907,9 +1904,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1942,7 +1936,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1942,7 +1936,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1981,7 +1974,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1981,7 +1974,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1996,7 +1988,7 @@ notificationManager.getActiveNotificationCount().then((data) => { ...@@ -1996,7 +1988,7 @@ notificationManager.getActiveNotificationCount().then((data) => {
## notificationManager.getActiveNotifications ## notificationManager.getActiveNotifications
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains active notifications of this application. This API uses an asynchronous callback to return the result. Obtains active notifications of this application. This API uses an asynchronous callback to return the result.
...@@ -2006,7 +1998,7 @@ Obtains active notifications of this application. This API uses an asynchronous ...@@ -2006,7 +1998,7 @@ Obtains active notifications of this application. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#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**
...@@ -2014,7 +2006,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2014,7 +2006,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2053,7 +2044,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2053,7 +2044,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2087,7 +2077,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2087,7 +2077,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2128,7 +2117,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2128,7 +2117,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2168,9 +2156,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2168,9 +2156,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2218,9 +2203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2218,9 +2203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2261,9 +2243,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2261,9 +2243,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2313,9 +2292,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2313,9 +2292,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2361,9 +2337,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2361,9 +2337,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2417,9 +2390,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2417,9 +2390,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2467,9 +2437,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2467,9 +2437,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2513,9 +2480,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2513,9 +2480,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2555,9 +2519,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2555,9 +2519,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2610,9 +2571,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2610,9 +2571,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2652,9 +2610,6 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to ...@@ -2652,9 +2610,6 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2697,9 +2652,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2697,9 +2652,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2733,11 +2685,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2733,11 +2685,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**Example** **Example**
...@@ -2780,11 +2730,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2780,11 +2730,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**Example** **Example**
...@@ -2816,7 +2764,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2816,7 +2764,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2849,7 +2796,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2849,7 +2796,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2889,9 +2835,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2889,9 +2835,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2937,9 +2880,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2937,9 +2880,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2976,7 +2916,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2976,7 +2916,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3018,7 +2957,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3018,7 +2957,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3060,9 +2998,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3060,9 +2998,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3116,9 +3051,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3116,9 +3051,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3164,9 +3096,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3164,9 +3096,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3221,9 +3150,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3221,9 +3150,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3267,9 +3193,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3267,9 +3193,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3312,9 +3235,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3312,9 +3235,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3355,9 +3275,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3355,9 +3275,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3425,9 +3342,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3425,9 +3342,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3491,9 +3405,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3491,9 +3405,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3547,9 +3458,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3547,9 +3458,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3596,9 +3504,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3596,9 +3504,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3649,9 +3554,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3649,9 +3554,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3695,9 +3597,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3695,9 +3597,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3752,9 +3651,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3752,9 +3651,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3797,9 +3693,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3797,9 +3693,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3854,9 +3747,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3854,9 +3747,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3901,9 +3791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3901,9 +3791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3956,9 +3843,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3956,9 +3843,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3975,6 +3859,87 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => ...@@ -3975,6 +3859,87 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
}); });
``` ```
## notificationManager.on<sup>10+</sup>
on(type: 'checkNotification', callback: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;
Subscribes to notification events. The notification service sends the notification information in the callback to the verification program. The verification program returns the verification result to determine whether to publish the notification, for example, controlling the publish frequency of marketing notifications.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| type | string | Yes | Event type. The value is fixed to **'checkNotification'**.|
| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) => [NotificationCheckResult](#notificationcheckresult10) | Yes | Pointer to the notification verification function.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
**Example**
```ts
try{
notificationManager.on("checkNotification", OnCheckNotification);
} catch (error){
console.info(`notificationManager.on error: ${JSON.stringify(error)}`);
}
function OnCheckNotification(info : notificationManager.NotificationCheckInfo) {
console.info(`====>OnCheckNotification info: ${JSON.stringify(info)}`);
if(info.notificationId == 1){
return { code: 1, message: "testMsg1"}
} else {
return { code: 0, message: "testMsg0"}
}
}
```
## notificationManager.off<sup>10+</sup>
off(type: 'checkNotification', callback?: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;
Unsubscribes from notification events.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| type | string | Yes | Event type. The value is fixed to **'checkNotification'**.|
| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) => [NotificationCheckResult](#notificationcheckresult10) | No | Pointer to the notification verification function.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
**Example**
```ts
try{
notificationManager.off("checkNotification");
} catch (error){
console.info(`notificationManager.off error: ${JSON.stringify(error)}`);
}
```
## DoNotDisturbDate ## DoNotDisturbDate
...@@ -3982,11 +3947,11 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => ...@@ -3982,11 +3947,11 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
**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 | Read-only| Mandatory| Description |
| ----- | ------------------------------------- | ---- | ---- | ---------------------- | | ----- | ------------------------------------- | ---- | ---- | ---------------------- |
| type | [DoNotDisturbType](#donotdisturbtype) | Yes | Yes | DND time type.| | type | [DoNotDisturbType](#donotdisturbtype) | No | Yes | DND time type.|
| begin | Date | Yes | Yes | DND start time.| | begin | Date | No | Yes | DND start time.|
| end | Date | Yes | Yes | DND end time.| | end | Date | No | Yes | DND end time.|
## DoNotDisturbType ## DoNotDisturbType
...@@ -4067,3 +4032,30 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => ...@@ -4067,3 +4032,30 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
| TYPE_NORMAL | 0 | Normal notification. | | TYPE_NORMAL | 0 | Normal notification. |
| TYPE_CONTINUOUS | 1 | Continuous notification. | | TYPE_CONTINUOUS | 1 | Continuous notification. |
| TYPE_TIMER | 2 | Timed notification. | | TYPE_TIMER | 2 | Timed notification. |
## NotificationCheckInfo<sup>10+</sup>
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
| Name | Type | Read-only| Mandatory| Description |
| ----- | ------------------------------------- | ---- | ---- | ---------------------- |
| bundleName | string | No | Yes | Bundle name.|
| notificationId | number | No | Yes | Notification ID. |
| contentType | [ContentType](#contenttype) | No | Yes | Notification type. |
## NotificationCheckResult<sup>10+</sup>
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
| Name | Type | Read-only| Mandatory| Description |
| ----- | ------------------------------------- | ---- | ---- | ---------------------- |
| code | number | No | Yes | Result code.<br>**0**: display.<br>**1**: no display.|
| message | string | No | Yes | Result. |
...@@ -12,8 +12,6 @@ The **notificationSubscribe** module provides APIs for notification subscription ...@@ -12,8 +12,6 @@ The **notificationSubscribe** module provides APIs for notification subscription
import notificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
``` ```
## NotificationSubscribe.subscribe ## NotificationSubscribe.subscribe
subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\<void\>): void subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\<void\>): void
...@@ -40,9 +38,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -40,9 +38,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -96,9 +91,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -96,9 +91,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -150,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -150,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -199,9 +188,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -199,9 +188,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -249,9 +235,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -249,9 +235,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -287,7 +270,7 @@ Removes a notification for a specified application. This API uses an asynchronou ...@@ -287,7 +270,7 @@ Removes a notification for a specified application. This API uses an asynchronou
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ----------------------------------| ---- | -------------------- | | --------------- | ----------------------------------| ---- | -------------------- |
| bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| notificationKey | [NotificationKey](js-apis-notification.md#notificationkey) | Yes | Notification key. | | notificationKey | [NotificationKey](#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.|
...@@ -297,9 +280,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -297,9 +280,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -346,7 +326,7 @@ Removes a notification for a specified application. This API uses a promise to r ...@@ -346,7 +326,7 @@ Removes a notification for a specified application. This API uses a promise to r
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | --------------- | ---- | ---------- | | --------------- | --------------- | ---- | ---------- |
| bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| | bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.|
| notificationKey | [NotificationKey]((js-apis-notification.md#notificationkey)) | Yes | Notification key. | | notificationKey | [NotificationKey](#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**
...@@ -355,9 +335,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -355,9 +335,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -374,7 +351,7 @@ let notificationKey = { ...@@ -374,7 +351,7 @@ 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).then(() => { notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
...@@ -396,7 +373,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu ...@@ -396,7 +373,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 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.| | hashCode | string | Yes | Unique notification ID. It is the **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) of the [onConsume](js-apis-inner-notification-notificationSubscriber.md#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.|
...@@ -406,9 +383,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -406,9 +383,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -426,7 +400,7 @@ function removeCallback(err) { ...@@ -426,7 +400,7 @@ function removeCallback(err) {
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);
``` ```
...@@ -455,9 +429,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -455,9 +429,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -489,7 +460,7 @@ Removes all notifications for a specified application. This API uses an asynchro ...@@ -489,7 +460,7 @@ Removes all notifications for a specified application. This API uses an asynchro
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------- | | -------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption]((js-apis-inner-notification-notificationCommonDef.md#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**
...@@ -498,9 +469,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -498,9 +469,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -519,7 +487,7 @@ function removeAllCallback(err) { ...@@ -519,7 +487,7 @@ function removeAllCallback(err) {
let bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
}; };
NotificationSubscribe.removeAll(bundle, removeAllCallback); notificationSubscribe.removeAll(bundle, removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
...@@ -546,9 +514,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -546,9 +514,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -583,7 +548,7 @@ Removes all notifications for a specified application. This API uses a promise t ...@@ -583,7 +548,7 @@ Removes all notifications for a specified application. This API uses a promise t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption]((js-apis-inner-notification-notificationCommonDef.md#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**
...@@ -591,9 +556,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -591,9 +556,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -633,9 +595,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -633,9 +595,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -657,7 +616,7 @@ let userId = 1; ...@@ -657,7 +616,7 @@ let userId = 1;
notificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## Notification.removeAll ## NotificationSubscribe.removeAll
removeAll(userId: number): Promise\<void> removeAll(userId: number): Promise\<void>
...@@ -681,9 +640,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -681,9 +640,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -705,359 +661,14 @@ let userId = 1; ...@@ -705,359 +661,14 @@ let userId = 1;
notificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## NotificationSubscriber ## NotificationKey
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribesubscribe).
**System API**: This is a system API and cannot be called by third-party applications.
### onConsume
onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a notification is received.
**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. | Name | Type | Read-only| Mandatory| Description |
| ----- | ------ | ---- | --- | -------- |
**Parameters** | id | number | No | Yes | Notification ID. |
| label | string | No | No | Notification label.|
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification received.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConsumeCallback(data) {
console.info('===> onConsume in test');
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
};
let subscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onCancel
onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a notification is canceled.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification to cancel.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onCancelCallback(data) {
console.info('===> onCancel in test');
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
}
let subscriber = {
onCancel: onCancelCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onUpdate
onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
Called when the notification sorting list is updated.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) | Yes| Latest notification sorting list.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
let subscriber = {
onUpdate: onUpdateCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onConnect
onConnect?:() => void
Called when subscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
let subscriber = {
onConnect: onConnectCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDisconnect
onDisconnect?:() => void
Called when unsubscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function unsubscribeCallback(err) {
if (err.code) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// The onConnect callback is invoked when subscription to the notification is complete.
notificationSubscribe.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
### onDestroy
onDestroy?:() => void
Callback for service disconnection.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDestroyCallback() {
console.info('===> onDestroy in test');
}
let subscriber = {
onDestroy: onDestroyCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDoNotDisturbDateChange
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void
Called when the DND time setting is updated.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | notification.[DoNotDisturbDate](js-apis-notificationManager.md#DoNotDisturbDate) | Yes| DND time setting updates.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onEnabledNotificationChanged
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)) => void
Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable);
};
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onBadgeChanged<sup>10+</sup>
onBadgeChanged?:(data: [BadgeNumberCallbackData](#badgenumbercallbackdata10)) => void
Listens for the change of the notification badge number.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[BadgeNumberCallbackData](#badgenumbercallbackdata10)\> | Yes | Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onBadgeChangedCallback(data) {
console.info("bundle: ", data.bundle);
console.info("uid: ", data.uid);
console.info("badgeNumber: ", data.badgeNumber);
};
let subscriber = {
onBadgeChanged: onBadgeChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
## RemoveReason ## RemoveReason
...@@ -1069,15 +680,3 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1069,15 +680,3 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | | CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. |
| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | | CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. |
## BadgeNumberCallbackData<sup>10+</sup>
**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 |
| ----------- | ------ | ---- | ---- | ------------ |
| bundle | string | Yes | No | Bundle name of the application.|
| uid | number | Yes | No | UID of the application. |
| badgeNumber | number | Yes | No | Notification badge number. |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册