diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md index 2d830a4b8318afdf61f4d9d7531e71a3a6420858..ac141ad75d108f68d25007491a15062ae958563e 100644 --- a/en/application-dev/quick-start/module-configuration-file.md +++ b/en/application-dev/quick-start/module-configuration-file.md @@ -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)| | exported | Whether the UIAbility component can be called by other applications.
- **true**: The UIAbility component can be called by other applications.
- **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).
- **true**: The UIAbility component can be migrated.
- **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.
Configuring rule:
- 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.)
- 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.
Configuration rules:
- 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.)
- 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.
Continuous tasks are classified into the following types:
- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.
- **audioPlayback**: audio playback service.
- **audioRecording**: audio recording service.
- **location**: location and navigation services.
- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).
- **multiDeviceConnection**: multi-device interconnection service.
- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)
- **voip**: voice/video call and VoIP services.
- **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**.
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**.
The value is a string with a maximum of 255 bytes.| String| No| diff --git a/en/application-dev/quick-start/quickfix-principles.md b/en/application-dev/quick-start/quickfix-principles.md index 4c0a1f684cfc1ff71c5ad9a2594ae8823e178e82..7af7d25c2b04172246034484bd0529d6453e7ef1 100644 --- a/en/application-dev/quick-start/quickfix-principles.md +++ b/en/application-dev/quick-start/quickfix-principles.md @@ -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. * 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. -* 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 diff --git a/en/application-dev/quick-start/start-with-ets-fa.md b/en/application-dev/quick-start/start-with-ets-fa.md index 019490d354b8d7c6b6ff7771065aae1b7534b76c..36fe7adfb84fa9ea5a5e735a61d71ca44dbe6dab 100644 --- a/en/application-dev/quick-start/start-with-ets-fa.md +++ b/en/application-dev/quick-start/start-with-ets-fa.md @@ -10,7 +10,7 @@ ## 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) diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md index d18a01875cf2e52abd45b493f8223c596912276d..978ffd47a206abc5f5b3e047a8d7f3dcc0e599e9 100644 --- a/en/application-dev/quick-start/start-with-ets-stage.md +++ b/en/application-dev/quick-start/start-with-ets-stage.md @@ -10,7 +10,7 @@ ## 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) diff --git a/en/application-dev/quick-start/start-with-js-fa.md b/en/application-dev/quick-start/start-with-js-fa.md index abb27d9fb942a406e22d98285626984bdc63d197..812be6247b4ed3aae55dd1f67b0ee5bb47f01065 100644 --- a/en/application-dev/quick-start/start-with-js-fa.md +++ b/en/application-dev/quick-start/start-with-js-fa.md @@ -8,7 +8,7 @@ ## 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) diff --git a/en/application-dev/reference/apis/js-apis-commonEvent.md b/en/application-dev/reference/apis/js-apis-commonEvent.md index 1496c18abf062e412dcc36368d046992b7f95c69..5a4af7f39f321fc486a4e359b567666dc359135a 100644 --- a/en/application-dev/reference/apis/js-apis-commonEvent.md +++ b/en/application-dev/reference/apis/js-apis-commonEvent.md @@ -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. > **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 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 For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md). -## CommonEvent.publish +## CommonEvent.publish(deprecated) -```ts -publish(event: string, callback: AsyncCallback): void -``` +publish(event: string, callback: AsyncCallback\): void 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 **Parameters** @@ -52,14 +55,16 @@ function publishCB(err) { CommonEvent.publish("event", publishCB); ``` -## CommonEvent.publish +## CommonEvent.publish(deprecated) -```ts -publish(event: string, options: CommonEventPublishData, callback: AsyncCallback): void -``` +publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\): void 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 **Parameters** @@ -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. | | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.| -| callback | syncCallback\ | Yes | Callback used to return the result. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -94,14 +99,16 @@ function publishCB(err) { CommonEvent.publish("event", options, publishCB); ``` -## CommonEvent.publishAsUser8+ +## CommonEvent.publishAsUser(deprecated) -```ts -publishAsUser(event: string, userId: number, callback: AsyncCallback): void -``` +publishAsUser(event: string, userId: number, callback: AsyncCallback\): void 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 API**: This is a system API and cannot be called by third-party applications. @@ -133,14 +140,16 @@ let userId = 100; CommonEvent.publishAsUser("event", userId, publishCB); ``` -## CommonEvent.publishAsUser8+ +## CommonEvent.publishAsUser(deprecated) -```ts -publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback): void -``` +publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\): void 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 API**: This is a system API and cannot be called by third-party applications. @@ -180,14 +189,16 @@ let userId = 100; CommonEvent.publishAsUser("event", userId, options, publishCB); ``` -## CommonEvent.createSubscriber +## CommonEvent.createSubscriber(deprecated) -```ts -createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback): void -``` +createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\): void 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 **Parameters** @@ -222,14 +233,16 @@ function createCB(err, commonEventSubscriber) { CommonEvent.createSubscriber(subscribeInfo, createCB); ``` -## CommonEvent.createSubscriber +## CommonEvent.createSubscriber(deprecated) -```ts -createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise -``` +createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ 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 **Parameters** @@ -262,14 +275,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => { }); ``` -## CommonEvent.subscribe +## CommonEvent.subscribe(deprecated) -```ts -subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback): void -``` +subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\): void 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 **Parameters** @@ -314,14 +329,16 @@ function createCB(err, commonEventSubscriber) { CommonEvent.createSubscriber(subscribeInfo, createCB); ``` -## CommonEvent.unsubscribe +## CommonEvent.unsubscribe(deprecated) -```ts -unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback): void -``` +unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): void 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 **Parameters** diff --git a/en/application-dev/reference/apis/js-apis-commonEventManager.md b/en/application-dev/reference/apis/js-apis-commonEventManager.md index 292df5cbe51d1b257f37fc42d99b17f7d08ad813..61d22613c35ceb0556ab66748f635c3e92c7b412 100644 --- a/en/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/en/application-dev/reference/apis/js-apis-commonEventManager.md @@ -39,7 +39,6 @@ Publishes a common event and executes an asynchronous callback after the event i | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1500004 | not System services. | | 1500007 | error sending message to Common Event Service. | | 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 | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1500004 | not System services. | | 1500007 | error sending message to Common Event Service. | | 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 | ID| Error Message | | -------- | ----------------------------------- | -| 202 | not system app. | -| 401 | The parameter check failed. | | 1500004 | not System services. | | 1500007 | error sending message to Common Event Service. | | 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 | ID| Error Message | | -------- | ----------------------------------- | -| 202 | not system app. | -| 401 | The parameter check failed. | -| 1500004 | not System services. | +| 1500004 | not System services or System app. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | | 1500009 | error obtaining system parameters. | @@ -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. | | 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** - ```ts 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. | --------------------------------------------------------- | ---------------- | | 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** ```ts @@ -356,7 +333,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 801 | capability not supported. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | @@ -426,7 +402,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 801 | capability not supported. | | 1500007 | error sending message to Common Event Service. | | 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 **Required permissions**: ohos.permission.COMMONEVENT_STICKY +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name | Type | Mandatory| Description | @@ -508,12 +485,9 @@ Removes a sticky common event. This API uses an asynchronous callback to return | 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. | -| 1500007 | The message send error. | -| 1500008 | The CEMS error. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | **Example** @@ -525,7 +499,6 @@ CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => { return; } 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. **Required permissions**: ohos.permission.COMMONEVENT_STICKY +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type | Mandatory| Description | @@ -557,20 +532,102 @@ Removes a sticky common event. This API uses a promise to return the result. | 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. | -| 1500007 | The message send error. | -| 1500008 | The CEMS error. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | **Example** ```ts -commonEventManager.removeStickyCommonEvent("sticky_event").then(() => { +CommonEventManager.removeStickyCommonEvent("sticky_event").then(() => { console.info(`Remove sticky event AsyncCallback success`); }).catch ((err) => { console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`); }); ``` + +## CommonEventManager.setStaticSubscriberState10+ + +setStaticSubscriberState(enable: boolean, callback: AsyncCallback\): 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.
**true**: enabled.
**false**: disabled.| +| callback | AsyncCallback\ | 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.setStaticSubscriberState10+ + +setStaticSubscriberState(enable: boolean): Promise\; + +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.
**true**: enabled.
**false**: disabled.| + +**Return value** + +| Type | Description | +| -------------- | ---------------------------- | +| Promise\ | 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}`); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md index a73c80d7c5fa09e19f901b3c947f445eb61989e1..a8afc035794c4e35fbdf9d68a715fe2bb67e7b36 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md @@ -1,5 +1,10 @@ # 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 | Name | Type | Readable| Writable| Description | diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md index 94963860fe1b57a6abfd6fff6fdba38816a63294..332fd934c7ee9799d4356acc45996d3632b4f9d2 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md @@ -1,5 +1,9 @@ # 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 | Name | Type | Readable| Writable| Description | diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md index 2b9db9ec46f479d5d0607c33f07601b1ef721446..c5de47b81e6b928a7d26909a54aa9ba798078417 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md @@ -1,5 +1,9 @@ # 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 | Name | Type | Readable| Writable| Description | diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md index 18eeac506b75dc96b27b56b9369070215ff8892a..02112d5b265e73139c9cd662246a819bc16c0b1f 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md @@ -1,11 +1,40 @@ # 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 -getCode(callback: AsyncCallback): 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\): void + Obtains the code of this common event. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.CommonEvent @@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result code obtaining of an ordered common event. function getCodeCB(err, code) { if (err.code) { @@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB); ## getCode -```ts -getCode(): Promise -``` +getCode(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getCode().then((code) => { console.info("getCode " + JSON.stringify(code)); }).catch((err) => { @@ -62,9 +85,7 @@ subscriber.getCode().then((code) => { ## setCode -```ts -setCode(code: number, callback: AsyncCallback): void -``` +setCode(code: number, callback: AsyncCallback\): void 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result code setting of an ordered common event. function setCodeCB(err) { if (err.code) { @@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB); ## setCode -```ts -setCode(code: number): Promise -``` +setCode(code: number): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.setCode(1).then(() => { console.info("setCode"); }).catch((err) => { @@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => { ## getData -```ts -getData(callback: AsyncCallback): void -``` +getData(callback: AsyncCallback\): void 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result data obtaining of an ordered common event. function getDataCB(err, data) { if (err.code) { @@ -161,9 +172,7 @@ subscriber.getData(getDataCB); ## getData -```ts -getData(): Promise -``` +getData(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getData().then((data) => { console.info("getData " + JSON.stringify(data)); }).catch((err) => { @@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result data setting of an ordered common event function setDataCB(err) { if (err.code) { @@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB); ## setData -```ts -setData(data: string): Promise -``` +setData(data: string): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.setData("publish_data_changed").then(() => { console.info("setData"); }).catch((err) => { @@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => { ## setCodeAndData -```ts -setCodeAndData(code: number, data: string, callback:AsyncCallback): void -``` +setCodeAndData(code: number, data: string, callback:AsyncCallback\): void 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for code and data setting of an ordered common event. function setCodeDataCB(err) { if (err.code) { @@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB); ## setCodeAndData -```ts -setCodeAndData(code: number, data: string): Promise -``` +setCodeAndData(code: number, data: string): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.setCodeAndData(1, "publish_data_changed").then(() => { console.info("setCodeAndData"); }).catch((err) => { @@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => { ## isOrderedCommonEvent -```ts -isOrderedCommonEvent(callback: AsyncCallback): void -``` +isOrderedCommonEvent(callback: AsyncCallback\): void 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for checking whether the current common event is an ordered one. function isOrderedCB(err, isOrdered) { if (err.code) { @@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB); ## isOrderedCommonEvent -```ts -isOrderedCommonEvent(): Promise -``` +isOrderedCommonEvent(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.isOrderedCommonEvent().then((isOrdered) => { console.info("isOrdered " + JSON.stringify(isOrdered)); }).catch((err) => { @@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => { ## isStickyCommonEvent -```ts -isStickyCommonEvent(callback: AsyncCallback): void -``` +isStickyCommonEvent(callback: AsyncCallback\): void 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for checking whether the current common event is a sticky one. function isStickyCB(err, isSticky) { if (err.code) { @@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB); ## isStickyCommonEvent -```ts -isStickyCommonEvent(): Promise -``` +isStickyCommonEvent(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.isStickyCommonEvent().then((isSticky) => { console.info("isSticky " + JSON.stringify(isSticky)); }).catch((err) => { @@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => { ## abortCommonEvent -```ts -abortCommonEvent(callback: AsyncCallback): void -``` +abortCommonEvent(callback: AsyncCallback\): 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. @@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for common event aborting. function abortCB(err) { if (err.code) { @@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB); ## abortCommonEvent -```ts -abortCommonEvent(): Promise -``` +abortCommonEvent(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.abortCommonEvent().then(() => { console.info("abortCommonEvent"); }).catch((err) => { @@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => { ## clearAbortCommonEvent -```ts -clearAbortCommonEvent(callback: AsyncCallback): void -``` +clearAbortCommonEvent(callback: AsyncCallback\): 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. @@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for clearing the aborted state of the current common event. function clearAbortCB(err) { if (err.code) { @@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB); ## clearAbortCommonEvent -```ts -clearAbortCommonEvent(): Promise -``` +clearAbortCommonEvent(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.clearAbortCommonEvent().then(() => { console.info("clearAbortCommonEvent"); }).catch((err) => { @@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => { ## getAbortCommonEvent -```ts -getAbortCommonEvent(callback: AsyncCallback): void -``` +getAbortCommonEvent(callback: AsyncCallback\): 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. @@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for checking whether the current common event is in the aborted state. function getAbortCB(err, abortEvent) { if (err.code) { @@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB); ## getAbortCommonEvent -```ts -getAbortCommonEvent(): Promise -``` +getAbortCommonEvent(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getAbortCommonEvent().then((abortEvent) => { console.info("abortCommonEvent " + JSON.stringify(abortEvent)); }).catch((err) => { @@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => { ## getSubscribeInfo -```ts -getSubscribeInfo(callback: AsyncCallback): void -``` +getSubscribeInfo(callback: AsyncCallback\): void 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for subscriber information obtaining. function getCB(err, subscribeInfo) { if (err.code) { @@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB); ## getSubscribeInfo -```ts -getSubscribeInfo(): Promise -``` +getSubscribeInfo(): Promise\ 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** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getSubscribeInfo().then((subscribeInfo) => { console.info("subscribeInfo " + JSON.stringify(subscribeInfo)); }).catch((err) => { @@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => { ## finishCommonEvent9+ -```ts -finishCommonEvent(callback: AsyncCallback): void -``` +finishCommonEvent(callback: AsyncCallback\): void 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for ordered common event finishing. function finishCB(err) { if (err.code) { console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`); -} else { + } else { console.info("FinishCommonEvent"); + } } subscriber.finishCommonEvent(finishCB); @@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB); ## finishCommonEvent9+ -```ts -finishCommonEvent(): Promise -``` +finishCommonEvent(): Promise\ 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 **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.finishCommonEvent().then(() => { console.info("FinishCommonEvent"); }).catch((err) => { diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md index 88e58e4bea766398e24ae1870c061e0dc385953a..ee7f0e37c7d85cdfdde76ae9b852bb05964af358 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md @@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no **System capability**: SystemCapability.Notification.Notification -| Name | Type | Readable| Writable| Description | +| Name | Type | Read-only| Mandatory| 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. | -| userInput8+ | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | Yes | Yes | User input object. | +| title | string | No | Yes | Button title. | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | Yes | **WantAgent** of the button.| +| extras | { [key: string]: any } | No | No | Extra information of the button. | +| userInput8+ | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | No | No | User input object. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md index dcd2a4ce8de27431ea343b27bb933d829fcad74c..48f8c4cc28912aab4b3cc0446c951fe539b6ba4e 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md @@ -10,7 +10,7 @@ Provides the bundle information of an application. **System capability**: SystemCapability.Notification.Notification -| Name | Type | Mandatory| Description | -| ------ | ------ |---- | ------ | -| bundle | string | Yes| Bundle information of the application.| -| uid | number | No| User ID.| +| Name | Type | Read-only| Mandatory| Description | +| ------ | ------ | ---- | ---- | ------ | +| bundle | string | No | Yes| Bundle information of the application.| +| uid | number | No | No| User ID.| diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md index 7c2b3a78da9b2c22c7ae9967552655f6e70a6c8c..9f5de8d911f2533c0dd789fd3bce1eeaf1adeef6 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md @@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content. **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. | -| 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. | +| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | No | Yes | Notification content type. | +| normal | [NotificationBasicContent](#notificationbasiccontent) | No | No | Normal text. | +| longText | [NotificationLongTextContent](#notificationlongtextcontent) | No | No | Long text.| +| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | No | No | Multi-line text. | +| picture | [NotificationPictureContent](#notificationpicturecontent) | No | No | Picture-attached. | ## NotificationBasicContent @@ -22,11 +22,11 @@ Describes the normal text notification. **System capability**: SystemCapability.Notification.Notification -| Name | Type | Readable| Writable| Description | +| Name | Type | Read-only| Mandatory| Description | | -------------- | ------ | ---- | ---- | ---------------------------------- | -| title | string | Yes | Yes | Notification title. | -| text | string | Yes | Yes | Notification content. | -| additionalText | string | Yes | Yes | Additional information of the notification.| +| title | string | No | Yes | Notification title. | +| text | string | No | Yes | Notification content. | +| additionalText | string | No | No | Additional information of the notification.| ## NotificationLongTextContent @@ -35,14 +35,14 @@ Describes the long text notification. **System capability**: SystemCapability.Notification.Notification -| Name | Type | Readable| Writable| Description | +| Name | Type | Read-only| Mandatory| 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. | +| title | string | No | Yes | Notification title. | +| text | string | No | Yes | Notification content. | +| additionalText | string | No | No | Additional information of the notification.| +| longText | string | No | Yes | Long text of the notification. | +| briefText | string | No | Yes | Brief text of the notification. | +| expandedTitle | string | No | Yes | Title of the notification in the expanded state. | ## NotificationMultiLineContent @@ -53,12 +53,12 @@ Describes the multi-line text 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\ | Yes | Yes | Multi-line text of the notification. | +| title | string | No | Yes | Notification title. | +| text | string | No | Yes | Notification content. | +| additionalText | string | No | No | Additional information of the notification.| +| briefText | string | No | Yes | Brief text of the notification.| +| longTitle | string | No | Yes | Title of the notification in the expanded state. | +| lines | Array\ | No | Yes | Multi-line text of the notification. | ## NotificationPictureContent @@ -69,9 +69,9 @@ Describes the picture-attached 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. | +| title | string | No | Yes | Notification title. | +| text | string | No | Yes | Notification content. | +| additionalText | string | No | No | Additional information of the notification.| +| briefText | string | No | Yes | Brief text of the notification.| +| expandedTitle | string | No | Yes | Title of the notification in the expanded state. | +| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Yes | Picture attached to the notification. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md index f7e1a995b51bcc193e2cd21115eb8e934233eec5..e0b84a9fbac8e59070b598960bdb447c9cc24dbe 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md @@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance. **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. | | vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md index 205a6c04bdf7fff97c80e44b882fb487712e2c01..ac3646f424f7701e2fa85c671a76ba90c511d212 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md @@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request. **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. | -| id | number | Yes | Yes | Notification ID. | -| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. | -| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. | -| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. | -| deliveryTime | number | Yes | Yes | Time when the notification is sent. | -| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. | -| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. | -| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked.| -| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. | -| color | number | Yes | Yes | Background color of the notification. Not supported currently.| -| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.| -| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.| -| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. | -| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. | -| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. | -| label | string | Yes | Yes | Notification label. | -| badgeIconStyle | number | Yes | Yes | Notification badge type. | -| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. | -| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | Yes | Yes | Buttons in the notification. Up to three buttons are allowed. | -| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.| -| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.| +| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | No | Yes | Notification content. | +| id | number | No | No | Notification ID. | +| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | No | Notification slot type. | +| isOngoing | boolean | No | No | Whether the notification is an ongoing notification. | +| isUnremovable | boolean | No | No | Whether the notification can be removed. | +| deliveryTime | number | No | No | Time when the notification is sent. | +| tapDismissed | boolean | No | No | Whether the notification is automatically cleared. | +| autoDeletedTime | number | No | No | Time when the notification is automatically cleared. | +| 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} | No | No | Extended parameters. | +| color | number | No | No | Background color of the notification. Not supported currently.| +| colorEnabled | boolean | No | No | Whether the notification background color can be enabled. Not supported currently.| +| isAlertOnce | boolean | No | No | Whether the notification triggers an alert only once.| +| isStopwatch | boolean | No | No | Whether to display the stopwatch. | +| isCountDown | boolean | No | No | Whether to display the countdown time. | +| isFloatingIcon | boolean | No | No | Whether the notification is displayed as a floating icon in the status bar. | +| label | string | No | No | Notification label. | +| badgeIconStyle | number | No | No | Notification badge type. Not supported currently. | +| showDeliveryTime | boolean | No | No | Whether to display the time when the notification is delivered. | +| 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) | 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) | 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. | | creatorUid8+ | number | Yes | No | UID used for creating the notification. | | creatorPid | number | Yes | No | PID used for creating the notification. | -| creatorUserId| number | Yes | No | ID of the user who creates the notification. | +| creatorUserId | number | Yes | No | ID of the user who creates the notification. | | hashCode | string | Yes | No | Unique ID of the notification. | -| classification | string | Yes | Yes | Notification category.
**System API**: This is a system API and cannot be called by third-party applications. | -| groupName8+ | string | Yes | Yes | Notification group name. | -| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. | +| classification | string | No | No | Notification category.
**System API**: This is a system API and cannot be called by third-party applications. | +| groupName8+ | string | No | No | Notification group name. | +| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | No | Notification template. | | isRemoveAllowed8+ | boolean | Yes | No | Whether the notification can be removed.
**System API**: This is a system API and cannot be called by third-party applications. | | source8+ | number | Yes | No | Notification source.
**System API**: This is a system API and cannot be called by third-party applications. | -| distributedOption8+ | [DistributedOptions](#distributedoptions) | Yes | Yes | Distributed notification options. | +| distributedOption8+ | [DistributedOptions](#distributedoptions) | No | No | Distributed notification options. | | deviceId8+ | string | Yes | No | Device ID of the notification source.
**System API**: This is a system API and cannot be called by third-party applications. | -| notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | Yes | No | Notification flags. | -| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. | -| badgeNumber9+ | number | Yes | Yes | Number of notifications displayed on the application icon. | +| notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | Yes | No | Notification flags. | +| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected when it is removed. | +| badgeNumber9+ | number | No | No | Number of notifications displayed on the application icon. | ## DistributedOptions @@ -55,9 +55,9 @@ Describes distributed notification options. **System capability**: SystemCapability.Notification.Notification -| Name | Type | Readable| Writable| Description | +| Name | Type | Read-only| Mandatory| Description | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- | -| isDistributed8+ | boolean | Yes | Yes | Whether the notification is a distributed notification. | -| supportDisplayDevices8+ | Array\ | Yes | Yes | List of the devices to which the notification can be synchronized. | -| supportOperateDevices8+ | Array\ | Yes | Yes | List of the devices on which the notification can be opened. | +| isDistributed8+ | boolean | No | No | Whether the notification is a distributed notification. | +| supportDisplayDevices8+ | Array\ | No | No | List of the devices to which the notification can be synchronized. | +| supportOperateDevices8+ | Array\ | No | No | List of the devices on which the notification can be opened. | | remindType8+ | number | Yes | No | Notification reminder type.
**System API**: This is a system API and cannot be called by third-party applications. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md index 8bf9e286d59504be03ff8454d59ce60c31a9a597..9757ef2c007501439c509adc691e8f57aa3b354c 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md @@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot. **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. | -| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.| -| desc | string | Yes | Yes | Notification slot description. | -| badgeFlag | boolean | Yes | Yes | Whether to display the badge. | -| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. | -| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. | -| vibrationEnabled | boolean | Yes | Yes | Whether to enable vibration for the notification. | -| sound | string | Yes | Yes | Notification alert tone. | -| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. | -| lightColor | number | Yes | Yes | Indicator color of the notification. | -| vibrationValues | Array\ | Yes | Yes | Vibration mode of the notification. | +| type | [SlotType](js-apis-notificationManager.md#slottype) | No | Yes | Notification slot type. | +| 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 | No | No | Notification slot description. | +| badgeFlag | boolean | No | No | Whether to display the badge. | +| bypassDnd | boolean | No | No | Whether to bypass DND mode in the system. | +| lockscreenVisibility | number | No | No | Mode for displaying the notification on the lock screen. | +| vibrationEnabled | boolean | No | No | Whether to enable vibration for the notification. | +| sound | string | No | No | Notification alert tone. | +| lightEnabled | boolean | No | No | Whether the indicator blinks for the notification. | +| lightColor | number | No | No | Indicator color of the notification. | +| vibrationValues | Array\ | No | No | Vibration mode of the notification. | | enabled9+ | boolean | Yes | No | Whether the notification slot is enabled. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md new file mode 100644 index 0000000000000000000000000000000000000000..8062a16f3ac0305025130bcd73f91bd41ba6abdf --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md @@ -0,0 +1,17 @@ +# 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. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSortingMap.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSortingMap.md new file mode 100644 index 0000000000000000000000000000000000000000..0e75e98d2ce00b55aefc7d640f6590332782b451 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSortingMap.md @@ -0,0 +1,17 @@ +# 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\ | Yes | Yes | Hash codes for notification sorting.| + diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscribeInfo.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscribeInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..8bd477d99c99ba3cc5f494b12fb83c993b0ca682 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscribeInfo.md @@ -0,0 +1,16 @@ +# 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\ | No | No | Bundle names of the applications whose notifications are to be subscribed to. | +| userId | number | No | No | User ID. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscriber.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscriber.md new file mode 100644 index 0000000000000000000000000000000000000000..cd23687ebc1da6055172deede38ab03b62e68c0c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscriber.md @@ -0,0 +1,402 @@ +# 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); +``` + +### onDoNotDisturbDateChange8+ + +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); +``` + + +### onEnabledNotificationChanged8+ + +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); +``` + +### onBadgeChanged10+ + + 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\ | Yes | No | Vibration used for notification.| + + +## EnabledNotificationCallbackData8+ + +**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.| + + +## BadgeNumberCallbackData10+ + +**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. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md index 557fad664de00eb37567cb2d055c0c0ec2f8d484..3f9825e1d8cf63848d70e2282498e0d85f37cab0 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md @@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template. **System capability**: SystemCapability.Notification.Notification -| Name| Type | Readable| Writable| Description | +| Name| Type | Read-only| Mandatory| Description | | ---- | ---------------------- | ---- | ---- | ---------- | -| name | string | Yes | Yes | Template name.| -| data | {[key:string]: Object} | Yes | Yes | Template data.| +| name | string | No | Yes | Template name.| +| data | {[key:string]: Object} | No | Yes | Template data.| diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md index 76e673c886d4208354b680501c6ddbb0000e6438..bfda17b7872a816c4eb05a3af9fc5c10098f0a90 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md @@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input. **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.| diff --git a/en/application-dev/reference/apis/js-apis-notification.md b/en/application-dev/reference/apis/js-apis-notification.md index b0ad704b1848025f7b049f9c0cda6d12f2175554..646f07fc4d30ec6ad4585eacd840a99954b34973 100644 --- a/en/application-dev/reference/apis/js-apis-notification.md +++ b/en/application-dev/reference/apis/js-apis-notification.md @@ -566,7 +566,7 @@ Notification.getSlot(slotType).then((data) => { ## Notification.getSlots -getSlots(callback: AsyncCallback>): void +getSlots(callback: AsyncCallback\>): void 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 | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\\> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Example** @@ -726,7 +726,7 @@ Subscribes to a notification with the subscription information specified. This A | 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.| | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -769,7 +769,7 @@ Subscribes to notifications of all applications under this user. This API uses a | Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | ---------------- | -| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | +| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -807,7 +807,7 @@ Subscribes to a notification with the subscription information specified. This A | 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. | **Example** @@ -840,7 +840,7 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu | Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | -------------------- | -| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | +| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -878,7 +878,7 @@ Unsubscribes from a notification. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | ------------ | -| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber.| +| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber.| **Example** @@ -910,7 +910,7 @@ Sets whether to enable notification for a specified application. This API uses a | 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. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -946,7 +946,7 @@ Sets whether to enable notification for a specified application. This API uses a | 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. | **Example** @@ -976,7 +976,7 @@ Checks whether notification is enabled for a specified application. This API use | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -1011,7 +1011,7 @@ Checks whether notification is enabled for a specified application. This API use | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.| **Return value** @@ -1078,7 +1078,7 @@ Checks whether notification is enabled for this application. This API uses a pro | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.| **Return value** @@ -1110,7 +1110,7 @@ Sets whether to enable the notification badge for a specified application. This | 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. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -1146,7 +1146,7 @@ Sets whether to enable the notification badge for a specified application. This | 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. | **Example** @@ -1176,7 +1176,7 @@ Checks whether the notification badge is enabled for a specified application. Th | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -1211,7 +1211,7 @@ Checks whether the notification badge is enabled for a specified application. Th | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.| **Return value** @@ -1246,7 +1246,7 @@ Sets the notification slot for a specified application. This API uses an asynchr | 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. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -1285,7 +1285,7 @@ Sets the notification slot for a specified application. This API uses a promise | 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.| **Example** @@ -1304,7 +1304,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ## Notification.getSlotsByBundle -getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void +getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\>): void 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 | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. | +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Example** @@ -1339,7 +1339,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ## Notification.getSlotsByBundle -getSlotsByBundle(bundle: BundleOption): Promise> +getSlotsByBundle(bundle: BundleOption): Promise\> 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 | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | Promise used to return the result.| +| Promise\> | Promise used to return the result.| **Example** @@ -1388,7 +1388,7 @@ Obtains the number of notification slots of a specified application. This API us | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -1423,7 +1423,7 @@ Obtains the number of notification slots of a specified application. This API us | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.| **Return value** @@ -1458,9 +1458,9 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal | Name | Type | Mandatory| Description | | --------------- | ----------------------------------| ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | -| reason | [RemoveReason](#removereason9) | Yes | Indicates the reason for deleting a notification. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. | +| notificationKey | [NotificationKey](#notificationkeydeprecated) | Yes | Notification key. | +| reason | [RemoveReason](#removereason9-deprecated) | Yes | Indicates the reason for deleting a notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -1500,9 +1500,9 @@ Removes a notification for a specified bundle. This API uses a promise to return | Name | Type | Mandatory| Description | | --------------- | --------------- | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application.| -| notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | -| reason | [RemoveReason](#removereason9) | Yes | Reason for deleting the notification. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application.| +| notificationKey | [NotificationKey](#notificationkeydeprecated) | Yes | Notification key. | +| reason | [RemoveReason](#removereason9-deprecated) | Yes | Reason for deleting the notification. | **Example** @@ -1536,8 +1536,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal | 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.| -| reason | [RemoveReason](#removereason9) | Yes | Indicates the reason for deleting a notification. | +| 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-deprecated) | Yes | Indicates the reason for deleting a notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -1573,7 +1573,7 @@ Removes a notification for a specified bundle. This API uses a promise to return | Name | Type | Mandatory| Description | | -------- | ---------- | ---- | ---------- | | 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** @@ -1601,7 +1601,7 @@ Removes all notifications for a specified application. This API uses an asynchro | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Bundle information of the application. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -1668,7 +1668,7 @@ Removes all notifications for a specified application. This API uses a promise t | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | No | Bundle information of the application.| +| bundle | [BundleOption](#bundleoptiondeprecated) | No | Bundle information of the application.| **Example** @@ -1743,7 +1743,7 @@ Notification.removeAll(userId).then(() => { ## Notification.getAllActiveNotifications -getAllActiveNotifications(callback: AsyncCallback>): void +getAllActiveNotifications(callback: AsyncCallback\>): void 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 | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | -------------------- | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Example** @@ -1775,7 +1775,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ## Notification.getAllActiveNotifications -getAllActiveNotifications(): Promise\\> +getAllActiveNotifications(): Promise\> 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 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\\> | Promise used to return the result.| +| Promise\> | Promise used to return the result.| **Example** @@ -1969,7 +1969,7 @@ Removes notifications under a notification group of a specified application. Thi | 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. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -2006,7 +2006,7 @@ Removes notifications under a notification group of a specified application. Thi | 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.| **Example** @@ -2035,7 +2035,7 @@ Sets the DND time. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------- | -| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set. | +| date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -2074,7 +2074,7 @@ Sets the DND time. This API uses a promise to return the result. | Name| Type | Mandatory| Description | | ---- | ---------------- | ---- | -------------- | -| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set.| +| date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set.| **Example** @@ -2106,7 +2106,7 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t | 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.| | callback | AsyncCallback\ | 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 | 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.| **Example** @@ -2183,7 +2183,7 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul | 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** @@ -2215,7 +2215,7 @@ Obtains the DND time. This API uses a promise to return the result. | Type | Description | | ------------------------------------------------- | ----------------------------------------- | -| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.| +| Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.| **Example** @@ -2242,7 +2242,7 @@ Obtains the DND time of a specified user. This API uses an asynchronous callback | 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.| **Example** @@ -2283,7 +2283,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the | Type | Description | | ------------------------------------------------- | ----------------------------------------- | -| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.| +| Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.| **Example** @@ -2589,7 +2589,7 @@ Sets whether a specified application supports distributed notifications. This AP | 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. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -2629,7 +2629,7 @@ Sets whether a specified application supports distributed notifications. This AP | 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. | **Example** @@ -2661,7 +2661,7 @@ Obtains whether an application supports distributed notifications based on the b | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Application bundle. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -2698,7 +2698,7 @@ Checks whether a specified application supports distributed notifications. This | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | +| bundle | [BundleOption](#bundleoptiondeprecated) | Yes | Application bundle. | **Return value** @@ -2735,7 +2735,7 @@ Obtains the notification reminder type. This API uses an asynchronous callback t | 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** @@ -2767,7 +2767,7 @@ Obtains the notification reminder type. This API uses a promise to return the re | Type | Description | | ------------------ | --------------- | -| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise used to return the result.| +| Promise\<[DeviceRemindType](#deviceremindtype8-deprecated)\> | Promise used to return the result.| **Example** @@ -2777,1033 +2777,255 @@ Notification.getDeviceRemindType().then((data) => { }); ``` - -## Notification.publishAsBundle9+ - -publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\): void - -Publishes an agent-powered notification. This API uses an asynchronous callback to return the result. +## SubscribeCallbackData **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. -**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\ | 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** +## EnabledNotificationCallbackData8+ -```js -// 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" - } - } -}; +**System capability**: SystemCapability.Notification.Notification -Notification.publishAsBundle(request, representativeBundle, userId, callback); -``` +**System API**: This is a system API and cannot be called by third-party applications. -## Notification.publishAsBundle9+ +| 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\ -Publishes a notification through the reminder agent. This API uses a promise to return the result. +## DoNotDisturbDate8+ deprecated **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. -**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 | -| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | -| 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. | +## DoNotDisturbType8+ deprecated -**Example** +**System capability**: SystemCapability.Notification.Notification -```js -// 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" - } - } -}; +> **NOTE** +> +> 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. -Notification.publishAsBundle(request, representativeBundle, userId).then(() => { - console.info("publishAsBundle success"); -}); -``` +**System API**: This is a system API and cannot be called by third-party applications. -## Notification.cancelAsBundle9+ +| 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 -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 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 | 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.| -**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 | -| -------------------- | ------------- | ---- | ------------------------ | -| 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. | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| 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.| -**Example** -```js -// 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; +## BundleOptiondeprecated -Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); -``` +**System capability**: SystemCapability.Notification.Notification -## Notification.cancelAsBundle9+ +> **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\ +| 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. +## NotificationKeydeprecated **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 - -**System API**: This is a system API and cannot be called by third-party applications. +> **NOTE** +> +> 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. -**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 -// 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; +**System capability**: SystemCapability.Notification.Notification -Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { - console.info("cancelAsBundle success"); -}); -``` +| 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.| -## Notification.enableNotificationSlot 9+ -enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\): 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 API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER +| 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. | +| userInput8+ | [NotificationUserInput](#notificationuserinput8) | Yes | Yes | User input object. | -**Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | ---------------------- | -| 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\ | Yes | Callback used to return the result.| +## NotificationBasicContent -**Example** +Describes the normal text notification. -```js -// enableNotificationSlot -function enableSlotCallback(err) { - if (err.code) { - console.info("enableNotificationSlot failed " + JSON.stringify(err)); - } else { - console.info("enableNotificationSlot success"); - } -}; +**System capability**: SystemCapability.Notification.Notification -Notification.enableNotificationSlot( - { bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION, - true, - enableSlotCallback); -``` +| 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.| -## Notification.enableNotificationSlot 9+ -enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\ +## 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 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 | -| ------ | ----------------------------- | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| type | [SlotType](#slottype) | Yes | Notification slot type.| -| enable | boolean | Yes | Whether to enable notification. | +Describes the multi-line text notification. -**Example** +**System capability**: SystemCapability.Notification.Notification -```js -// enableNotificationSlot -Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => { - console.info("enableNotificationSlot success"); -}); -``` +| 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\ | Yes | Yes | Multi-line text of the notification. | -## Notification.isNotificationSlotEnabled 9+ -isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\): 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 API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER +| 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. | -**Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| type | [SlotType](#slottype) | Yes | Notification slot type. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +## NotificationContent -**Example** +Describes the notification content. -```js -// isNotificationSlotEnabled -function getEnableSlotCallback(err, data) { - if (err.code) { - console.info("isNotificationSlotEnabled failed " + JSON.stringify(err)); - } else { - console.info("isNotificationSlotEnabled success"); - } -}; +**System capability**: SystemCapability.Notification.Notification -Notification.isNotificationSlotEnabled( - { bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION, - getEnableSlotCallback); -``` +| 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. | -## Notification.isNotificationSlotEnabled 9+ -isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ +## NotificationFlagStatus8+ -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 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 | -| ------ | ----------------------------- | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| type | [SlotType](#slottype) | Yes | Notification slot type.| - -**Return value** - -| Type | Description | -| ------------------ | ------------------------------- | -| Promise\ | 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)); -}); -``` - +| 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. | -## Notification.setSyncNotificationEnabledWithoutApp9+ -setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\): void +## NotificationFlags8+ -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 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 | -| ------ | ----------------------------- | ---- | -------------- | -| userId | number | Yes | User ID. | -| enable | boolean | Yes | Whether the feature is enabled. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +Describes the notification request. -**Example** - -```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.setSyncNotificationEnabledWithoutApp9+ - -setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\ - -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\ | 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.getSyncNotificationEnabledWithoutApp9+ - -getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\): 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\ | 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.getSyncNotificationEnabledWithoutApp9+ - -getSyncNotificationEnabledWithoutApp(userId: number): Promise\ - -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\ | 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); -``` - -### onDoNotDisturbDateChange8+ - -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"); -}); -``` - - -### onEnabledNotificationChanged8+ - -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\ | Yes | No | Vibration used for notification.| - - -## EnabledNotificationCallbackData8+ - -**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.| - - -## DoNotDisturbDate8+ - -**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.| - -## DoNotDisturbType8+ - -**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. | -| userInput8+ | [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\ | 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. | - - -## NotificationFlagStatus8+ - -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. | - - -## NotificationFlags8+ - -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 +**System capability**: SystemCapability.Notification.Notification | Name | Type | Readable| Writable| Description | | --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | @@ -3947,12 +3169,16 @@ Provides the notification user input. | inputKey | string | Yes | Yes | Key to identify the user input.| -## DeviceRemindType8+ +## DeviceRemindType8+ deprecated **System capability**: SystemCapability.Notification.Notification **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 | | -------------------- | --- | --------------------------------- | | IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. | @@ -3961,25 +3187,33 @@ Provides the notification user input. | ACTIVE_REMIND | 3 | The device is in use. | -## SourceType8+ +## SourceType8+ deprecated **System capability**: SystemCapability.Notification.Notification **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 | | -------------------- | --- | -------------------- | | TYPE_NORMAL | 0 | Normal notification. | | TYPE_CONTINUOUS | 1 | Continuous notification. | | TYPE_TIMER | 2 | Timed notification. | -## RemoveReason9+ +## RemoveReason9+ deprecated **System capability**: SystemCapability.Notification.Notification **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 | | -------------------- | --- | -------------------- | -| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | -| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | +| CLICK_REASON_REMOVE9+ | 1 | The notification is removed after a click on it. | +| CANCEL_REASON_REMOVE9+ | 2 | The notification is removed by the user. | diff --git a/en/application-dev/reference/apis/js-apis-notificationManager.md b/en/application-dev/reference/apis/js-apis-notificationManager.md index 3142a3daec90c4ac772e6a6f1e9d36572b9ee828..024b58e38329ce83b1f119d383ff697ad5df1a84 100644 --- a/en/application-dev/reference/apis/js-apis-notificationManager.md +++ b/en/application-dev/reference/apis/js-apis-notificationManager.md @@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -88,8 +87,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -209,8 +204,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 201 | Permission denied. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -265,7 +258,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -341,7 +332,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -375,7 +365,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -414,7 +403,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -452,9 +440,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -502,9 +487,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -543,7 +525,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -583,7 +564,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -622,9 +602,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -676,9 +653,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -721,7 +695,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -767,7 +740,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -783,7 +755,7 @@ notificationManager.getSlot(slotType).then((data) => { ## notificationManager.getSlots -getSlots(callback: AsyncCallback>): void +getSlots(callback: AsyncCallback\>): void 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/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -822,7 +793,7 @@ notificationManager.getSlots(getSlotsCallback); ## notificationManager.getSlots -getSlots(): Promise\> +getSlots(): Promise\> 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/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -874,7 +844,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -914,7 +883,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -948,7 +916,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -980,7 +947,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1019,9 +985,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1068,9 +1031,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1104,7 +1064,7 @@ Checks whether notification is enabled for a specified application. This API use | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------ | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Error codes** @@ -1112,9 +1072,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1166,9 +1123,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1201,7 +1155,7 @@ Checks whether notification is enabled for this application. This API uses an as | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Error codes** @@ -1209,9 +1163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -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. +**Return value** + +| Type | Description | +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| Promise\ | 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\): 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\ | 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\ + +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** | 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** @@ -1260,18 +1293,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 17700001 | The specified bundle name was not found. | +| 1600008 | The user is not exist.. | **Example** ```ts -notificationManager.isNotificationEnabled().then((data) => { +let userId = 1; + +notificationManager.isNotificationEnabled(userId).then((data) => { console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); }); ``` @@ -1302,9 +1334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1351,9 +1380,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1395,9 +1421,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1449,9 +1472,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1486,7 +1506,6 @@ Sets the notification badge number. This API uses a promise to return the result | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1522,7 +1541,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1569,9 +1587,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1621,9 +1636,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1645,7 +1657,7 @@ notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => { ## notificationManager.getSlotsByBundle -getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void +getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\>): void 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 | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------- | | bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application. | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Error codes** @@ -1668,9 +1680,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1694,7 +1703,7 @@ notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback); ## notificationManager.getSlotsByBundle -getSlotsByBundle(bundle: BundleOption): Promise> +getSlotsByBundle(bundle: BundleOption): Promise\> 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 | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | Promise used to return the result.| +| Promise\> | Promise used to return the result.| **Error codes** @@ -1722,9 +1731,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1766,9 +1772,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1820,9 +1823,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1842,7 +1842,7 @@ notificationManager.getSlotNumByBundle(bundle).then((data) => { ## notificationManager.getAllActiveNotifications -getAllActiveNotifications(callback: AsyncCallback>): void +getAllActiveNotifications(callback: AsyncCallback\>): void 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 | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | -------------------- | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Error codes** | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1907,9 +1904,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1942,7 +1936,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1981,7 +1974,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1996,7 +1988,7 @@ notificationManager.getActiveNotificationCount().then((data) => { ## notificationManager.getActiveNotifications -getActiveNotifications(callback: AsyncCallback>): void +getActiveNotifications(callback: AsyncCallback\>): void 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 | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Error codes** @@ -2014,7 +2006,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2053,7 +2044,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2087,7 +2077,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2128,7 +2117,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2168,9 +2156,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2218,9 +2203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2261,9 +2243,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2313,9 +2292,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2361,9 +2337,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2417,9 +2390,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2467,9 +2437,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2513,9 +2480,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2555,9 +2519,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2610,9 +2571,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2652,9 +2610,6 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2697,9 +2652,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2733,11 +2685,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 1600011 | Read template config failed. | **Example** @@ -2780,11 +2730,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 1600011 | Read template config failed. | **Example** @@ -2816,7 +2764,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2849,7 +2796,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2889,9 +2835,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2937,9 +2880,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2976,7 +2916,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3018,7 +2957,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3060,9 +2998,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3116,9 +3051,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3164,9 +3096,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3221,9 +3150,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3267,9 +3193,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3312,9 +3235,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3355,9 +3275,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3425,9 +3342,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3491,9 +3405,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3547,9 +3458,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3596,9 +3504,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3649,9 +3554,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3695,9 +3597,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3752,9 +3651,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3797,9 +3693,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3854,9 +3747,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3901,9 +3791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3956,9 +3843,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3975,6 +3859,87 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => }); ``` +## notificationManager.on10+ + +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.off10+ + +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 @@ -3982,11 +3947,11 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => **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.| -| begin | Date | Yes | Yes | DND start time.| -| end | Date | Yes | Yes | DND end time.| +| type | [DoNotDisturbType](#donotdisturbtype) | No | Yes | DND time type.| +| begin | Date | No | Yes | DND start time.| +| end | Date | No | Yes | DND end time.| ## DoNotDisturbType @@ -4067,3 +4032,30 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => | TYPE_NORMAL | 0 | Normal notification. | | TYPE_CONTINUOUS | 1 | Continuous notification. | | TYPE_TIMER | 2 | Timed notification. | + +## NotificationCheckInfo10+ + +**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. | + +## NotificationCheckResult10+ + +**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.
**0**: display.
**1**: no display.| +| message | string | No | Yes | Result. | diff --git a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md index fa441c00c57cb994824aeb3cf061e623f5256089..0746cb7cb1defd1691cbab96898dbb6ad47996a3 100644 --- a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -12,8 +12,6 @@ The **notificationSubscribe** module provides APIs for notification subscription import notificationSubscribe from '@ohos.notificationSubscribe'; ``` - - ## NotificationSubscribe.subscribe subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\): void @@ -40,9 +38,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -96,9 +91,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -150,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -199,9 +188,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -249,9 +235,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -287,7 +270,7 @@ Removes a notification for a specified application. This API uses an asynchronou | Name | Type | Mandatory| Description | | --------------- | ----------------------------------| ---- | -------------------- | | 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. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -297,9 +280,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -346,7 +326,7 @@ Removes a notification for a specified application. This API uses a promise to r | Name | Type | Mandatory| Description | | --------------- | --------------- | ---- | ---------- | | 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. | **Error codes** @@ -355,9 +335,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -374,7 +351,7 @@ let notificationKey = { id: 0, label: "label", }; -let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; notificationSubscribe.remove(bundle, notificationKey, reason).then(() => { console.info("remove success"); }); @@ -396,7 +373,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu | 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. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -406,9 +383,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -426,7 +400,7 @@ function removeCallback(err) { console.info("remove success"); } } -let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; +let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; notificationSubscribe.remove(hashCode, reason, removeCallback); ``` @@ -455,9 +429,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -489,7 +460,7 @@ Removes all notifications for a specified application. This API uses an asynchro | 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\ | Yes | Callback used to return the result.| **Error codes** @@ -498,9 +469,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -519,7 +487,7 @@ function removeAllCallback(err) { let bundle = { bundle: "bundleName1", }; -NotificationSubscribe.removeAll(bundle, removeAllCallback); +notificationSubscribe.removeAll(bundle, removeAllCallback); ``` ## NotificationSubscribe.removeAll @@ -546,9 +514,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -583,7 +548,7 @@ Removes all notifications for a specified application. This API uses a promise t | 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** @@ -591,9 +556,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -633,9 +595,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -657,7 +616,7 @@ let userId = 1; notificationSubscribe.removeAll(userId, removeAllCallback); ``` -## Notification.removeAll +## NotificationSubscribe.removeAll removeAll(userId: number): Promise\ @@ -681,9 +640,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -705,359 +661,14 @@ let userId = 1; notificationSubscribe.removeAll(userId, removeAllCallback); ``` -## NotificationSubscriber - -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. +## NotificationKey **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 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); -``` - -### onBadgeChanged10+ - - 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); -``` - +| Name | Type | Read-only| Mandatory| Description | +| ----- | ------ | ---- | --- | -------- | +| id | number | No | Yes | Notification ID. | +| label | string | No | No | Notification label.| ## RemoveReason @@ -1069,15 +680,3 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback); | -------------------- | --- | -------------------- | | CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | | CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | - -## BadgeNumberCallbackData10+ - -**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. |