未验证 提交 3a3f56d0 编写于 作者: O openharmony_ci 提交者: Gitee

!18752 【3.2-Release】翻译完成 18367+17815+17898+18438

Merge pull request !18752 from ester.zhou/C2-18367
...@@ -302,7 +302,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json ...@@ -302,7 +302,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)| | continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuring rule:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)| | [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuration rules:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service. | Object array| Yes (initial value: left empty)|
| backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)| | backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No|
| startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No|
......
...@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers ...@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers
* The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail. * The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail.
* Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail. * Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail.
* The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail. * The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail.
* Installing an application update will delete quick fix package. * Installing an application update will delete the quick fix package.
## Structure of the Quick Fix Package ## Structure of the Quick Fix Package
......
...@@ -51,20 +51,20 @@ resources ...@@ -51,20 +51,20 @@ resources
| Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory | | Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory |
| ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | | ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.<br>Resource group subdirectories are located at the second-level subdirectories in the **base** directory to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectory](#resource-group-subdirectory).| **en_US** and **zh_CN** are two default qualifiers subdirectories. You need to create other qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectory](#qualifiers-subdirectory).<br>Resource group subdirectories are located at the second level of qualifiers subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectory](#resource-group-subdirectory).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.<br>However, resource files in the **rawfile** subdirectory will not be matched based on the device status.| | Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.<br>Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| **en_US** and **zh_CN** are two default qualifiers subdirectories. You need to create other qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).<br>Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.<br>However, resource files in the **rawfile** subdirectory will not be matched based on the device status.|
| Compilation| Resource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | | Compilation| Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. |
| Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. | | Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. |
### Qualifiers Subdirectory ### Qualifiers Subdirectories
The name of a qualifiers subdirectory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). When creating a qualifiers subdirectory, you need to understand the directory naming conventions and the rules for matching qualifiers subdirectories and the device status. The name of a qualifiers subdirectory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). Before creating a qualifiers subdirectory, familiarize yourself with the directory naming conventions and the rules for matching qualifiers subdirectories and the device status.
**Naming Conventions for Qualifiers Subdirectories** **Naming Conventions for Qualifiers Subdirectories**
- Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density**. You can select one or multiple qualifiers to name your subdirectory based on your application scenarios and device characteristics. - Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density_**. You can select one or multiple qualifiers to name your subdirectory based on your application scenarios and device characteristics.
- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. - Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (\-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**.
- Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the resources directory cannot be matched. - Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the resources directory cannot be matched.
...@@ -72,23 +72,23 @@ The name of a qualifiers subdirectory consists of one or more qualifiers that re ...@@ -72,23 +72,23 @@ The name of a qualifiers subdirectory consists of one or more qualifiers that re
| Qualifier Type | Description and Value Range | | Qualifier Type | Description and Value Range |
| ----------- | ---------------------------------------- | | ----------- | ---------------------------------------- |
| MCC&MNC| Mobile country code and mobile network code, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (\_) in between or be used independently. For example, **mcc460** indicates China, and **mcc460\_mnc00** indicates China\_China Mobile.<br>For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions).| | MCC&MNC| Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (\_) in between or be used independently. For example, **mcc460** indicates China, and **mcc460\_mnc00** indicates China\_China Mobile.<br>For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions).|
| Language | Language used by the device. The value consists of two or three lowercase letters. for example, **zh** indicates Chinese, en indicates English, and **mai** indicates Maithili.<br>For details about the value range, refer to **ISO 639** (codes for the representation of names of languages).| | Language | Indicates the language used by the device. The value consists of two or three lowercase letters. For example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.<br>For details about the value range, refer to **ISO 639** (codes for the representation of names of languages).|
| Script | Script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.<br>For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts).|| | Text | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.<br>For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts).|
| Country/Region | Country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.<br>For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions).|| | Country/Region | Indicates the country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.<br>For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions).|
| Screen orientation | Screen orientation of the device. The value can be:<br>- **vertical**: portrait orientation<br>- **horizontal**: landscape orientation| | Screen orientation | Indicates the screen orientation of the device. The value can be:<br>- **vertical**: portrait orientation<br>- **horizontal**: landscape orientation|
| Type of the registered device. | Device type. The value can be:<br>- **car**: head unit<br>- **tv**: smart TV<br>- **wearable**: smart wearable| | Device type | Indicates the device type. The value can be:<br>- **car**: head unit<br>- **tv**: smart TV<br>- **wearable**: smart wearable|
| Color mode | Color mode of the device. The value can be:<br>- **dark**: dark mode<br>- **light**: light mode| | Color mode | Indicates the color mode of the device. The value can be:<br>- **dark**: dark mode<br>- **light**: light mode|
| Screen density | Screen density of the device, in dpi. The value can be:<br>- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].<br>- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].<br>- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].<br>- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].<br>- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].<br>- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].| | Screen density | Indicates the screen density of the device, in dpi. The value can be:<br>- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].<br>- **mdpi**: medium-scale screen density (Medium-scale Dots Per Inch), applicable to DPI whose value is (120, 160] device.<br>- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].<br>- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].<br>- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].<br>- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].|
**Rules for Matching Qualifiers subdirectories and Device Resources** **Rules for Matching Qualifiers Subdirectories and Device Resources**
- Qualifiers are matched with the device resources in the following priorities: MCC&MNC &gt; locale (options: language, language\_script, language\_country/region, and language\_script\_country/region) &gt; screen orientation &gt; device type &gt; color mode &gt; screen density. - Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density.
- If the qualifiers subdirectories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the subdirectories can be used for matching the device resources. For example, the qualifiers subdirectory **zh\_CN-car-ldpi** cannot be used for matching the resource files labeled **en\_US**. - If the qualifiers subdirectories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the subdirectories can be used for matching the device resources. For example, the qualifiers subdirectory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**.
### Resource Group Subdirectory ### Resource Group Subdirectories
You can create resource group subdirectories (including element, media, and profile) in the **base** and qualifiers subdirectories to store resource files of specific types. You can create resource group subdirectories (including element, media, and profile) in the **base** and qualifiers subdirectories to store resource files of specific types.
...@@ -97,9 +97,9 @@ You can create resource group subdirectories (including element, media, and prof ...@@ -97,9 +97,9 @@ You can create resource group subdirectories (including element, media, and prof
| Resource Group Subdirectory | Description | Resource File | | Resource Group Subdirectory | Description | Resource File |
| ------- | ---------------------------------------- | ---------------------------------------- | | ------- | ---------------------------------------- | ---------------------------------------- |
| element | Element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:<br>-&nbsp;boolean.json<br>-&nbsp;color.json<br>-&nbsp;float.json<br>-&nbsp;intarray.json<br>-&nbsp;integer.json<br>-&nbsp;pattern.json<br>-&nbsp;plural.json<br>-&nbsp;strarray.json<br>-&nbsp;string.json | | element | Indicates element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:<br>- boolean.json<br>- color.json<br>- float.json<br>- intarray.json<br>- integer.json<br>- pattern.json<br>- plural.json<br>- strarray.json<br>- string.json |
| media | Media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. | | media | Indicates media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. |
| profile | Custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. | | profile | Indicates a custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. |
**Media Resource Types** **Media Resource Types**
...@@ -212,41 +212,41 @@ The content of the **plural.json** file is as follows: ...@@ -212,41 +212,41 @@ The content of the **plural.json** file is as follows:
**Creating a Resource File** **Creating a Resource File**
You can create a subdirectory and its files under the **resources** directory based on the above descriptions of the qualifiers subdirectories and resource group subdirectories. You can create a subdirectory and its files under the **resources** directory based on the preceding descriptions of the qualifiers subdirectories and resource group subdirectories.
DevEco Studio provides a wizard for you to create resource directories and resource files. DevEco Studio provides a wizard for you to create resource directories and resource files.
- Creating a resource directory and resource file - Creating a Resource Directory and Resource File
Right-click the **resources** directory and choose **New > Resource File**. This operation creates a subdirectory and a resource file simultaneously. If no qualifier is selected, the file is created in a resource type subdirectory under **base**. If one or more qualifiers are selected, the system automatically generates a subdirectory and creates the file in this subdirectory. To select a qualifier, highlight it under **Available qualifiers** and click the right arrow. To deselect a qualifier, highlight it under **Selected qualifiers** and click the left arrow. In **File name**, enter the name of the resource file to create. In **Resource type**, select the type of the resource group, which is **element** by default. In **Root Element**, select a resource type. The created subdirectory is automatically named in the format of *Qualifiers.Resource group type*. For example, if you create a subdirectory by setting **Color Mode** to **Dark** and **Resource type** to **Element**, the system automatically generates a subdirectory named **dark.element**. Right-click the **resources** directory and choose **New > Resource File**. If no qualifier is selected, the file is created in a resource type subdirectory under **base**. If one or more qualifiers are selected, the system automatically generates a subdirectory and creates the file in this subdirectory. To select a qualifier, highlight it under **Available qualifiers** and click the right arrow. To deselect a qualifier, highlight it under **Selected qualifiers** and click the left arrow. In **File name**, enter the name of the resource file to create. In **Resource type**, select the type of the resource group, which is **element** by default. In **Root Element**, select a resource type. The created subdirectory is automatically named in the format of *Qualifiers.Resource group type*. For example, if you create a subdirectory by setting **Color Mode** to **Dark** and **Resource type** to **Element**, the system automatically generates a subdirectory named **dark.element**.
![create-resource-file-1](figures/create-resource-file-1.png) ![create-resource-file-1](figures/create-resource-file-1.png)
- Creating a resource directory - Creating a Resource Directory
Right-click the **resources** directory and choose **New > Resource Directory**. This operation creates a subdirectory only. By default, the **base** subdirectory is created. You can create qualifiers subdirectories as required, by specifying the qualifier and resource group type. After determining the qualifier, select a resource group type. Currently, the resource group type can be **Element**, **Media**, or **Profile**. After a resource group is created, a directory name is automatically generated. Right-click the **resources** directory and choose **New > Resource Directory** to create a subdirectory only. By default, the **base** subdirectory is created. You can create qualifiers subdirectories as required, by specifying the qualifier and resource group type.
![create-resource-file-2](figures/create-resource-file-2.png) ![create-resource-file-2](figures/create-resource-file-2.png)
- Creating a resource file - Creating a Resource File
Right-click a subdirectory under **resources** and choose **New > *example* Resource File**. This operation creates a resource file under this subdirectory. For example, you can create an element resource file in the **element** subdirectory. Right-click a subdirectory under **resources** and choose **New > *XXX* Resource File**. This operation creates a resource file under this subdirectory. For example, you can create an element resource file in the **element** subdirectory.
![create-resource-file-3](figures/create-resource-file-3.png) ![create-resource-file-3](figures/create-resource-file-3.png)
**Accessing Application Resources** **Accessing Application Resources**
To reference an application resource in a project, use the `"$r('app.type.name')"` format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. To reference an application resource in a project, use the **"$r('app.type.name')"** format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource.
When referencing resources in the **rawfile** subdirectory, use the `"$rawfile('filename')"` format. Wherein **filename** indicates the relative path of a file in the **rawfile** subdirectory, which must contain the file name extension and cannot start with a slash (/). When referencing resources in the **rawfile** subdirectory, use the **"$rawfile('filename')"** format. Wherein **filename** indicates the relative path of a file in the **rawfile** subdirectory, which must contain the file name extension and cannot start with a slash (/).
> **NOTE** > **NOTE**
> >
> Resource descriptors accept only strings, such as `'app.type.name'`, and cannot be combined. > Resource descriptors accept only strings, such as **'app.type.name'**, and cannot be combined.
> >
> The return value of `$r` is a Resource object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) method. > The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) API.
In the ***example*.ets** file, you can use the resources defined in the **resources** directory. The following is a resource usage example based on the resource file examples in [Resource Group Subdirectory](#resource-group-subdirectory): In the **.ets** file, you can use the resources defined in the **resources** directory. As described in [Resource Group Subdirectories](#resource-group-subdirectories), you can reference .json resource files, including **color.json**, **string.json**, and **plural.json**. The usage is as follows:
```ts ```ts
Text($r('app.string.string_hello')) Text($r('app.string.string_hello'))
...@@ -257,13 +257,14 @@ Text($r('app.string.string_world')) ...@@ -257,13 +257,14 @@ Text($r('app.string.string_world'))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world')) .fontSize($r('app.float.font_world'))
// Reference string resources. The second parameter of $r is used to replace %s, and value is "We will arrive at five of the clock". // Reference string resources. The first parameter of $r indicates the string resource, and the second parameter is used to replace %s in the string.json file.
// In this example, the resultant value is "We will arrive at five of the clock".
Text($r('app.string.message_arrive', "five of the clock")) Text($r('app.string.message_arrive', "five of the clock"))
.fontColor($r('app.color.color_hello')) .fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello')) .fontSize($r('app.float.font_hello'))
// Reference plural resources. The first parameter indicates the plural resource, the second parameter indicates the number of plural resources, and the third parameter indicates the substitute of %d. // Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, **one** indicates singular and is represented by **1**, and **other** indicates plural and is represented by an integer greater than or equal to 1; for Chinese, **other** indicates both singular and plural), and the third parameter is used to replace %d.
// The value is "5 apple" in singular form and "5 apples" in plural form. // In this example, the resultant value is "5 apples".
Text($r('app.plural.eat_apple', 5, 5)) Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world')) .fontSize($r('app.float.font_world'))
...@@ -279,13 +280,13 @@ Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile ...@@ -279,13 +280,13 @@ Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile
System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style. System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style.
To reference a system resource, use the `"$r('sys.type.resource_id')"` format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID. To reference a system resource, use the **"$r('sys.type.resource_id')"** format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID.
> **NOTE** > **NOTE**
> >
> - Use of system resources is supported in the declarative development paradigm, but not in the web-like development paradigm. > - Use of system resources is supported in the declarative development paradigm, but not in the web-like development paradigm.
> >
> - For details about the implementation of preconfigured resources, visit the [OpenHarmony/resources repository](https://gitee.com/openharmony/resources/tree/master/systemres/main/resources). The directory structure there is similar to that of the **resources** directory in the project. Resource qualifiers are used to match resources with different devices and device status. > - For details about the implementation of preconfigured resources, visit the [OpenHarmony/resources repository](https://gitee.com/openharmony/resources/tree/master/systemres/main/resources). The directory structure there is similar to that of the **resources** directory in the project. Resource qualifiers are used to match resources with different devices and device states.
```ts ```ts
Text('Hello') Text('Hello')
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## Creating a JavaScript Project ## Creating a JavaScript Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -19,12 +19,16 @@ A system common event is an event that is published by a system service or syste ...@@ -19,12 +19,16 @@ A system common event is an event that is published by a system service or syste
For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md). For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md).
## CommonEvent.publish ## CommonEvent.publish<sup>(deprecated)</sup>
publish(event: string, callback: AsyncCallback\<void>): void publish(event: string, callback: AsyncCallback\<void>): void
Publishes a common event. This API uses an asynchronous callback to return the result. Publishes a common event. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -50,14 +54,16 @@ function publishCallBack(err) { ...@@ -50,14 +54,16 @@ function publishCallBack(err) {
CommonEvent.publish("event", publishCallBack); CommonEvent.publish("event", publishCallBack);
``` ```
## CommonEvent.publish<sup>(deprecated)</sup>
## CommonEvent.publish
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
Publishes a common event with given attributes. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -66,7 +72,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca ...@@ -66,7 +72,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| event | string | Yes | Name of the common event to publish. | | event | string | Yes | Name of the common event to publish. |
| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.| | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.|
| callback | syncCallback\<void> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -92,14 +98,16 @@ function publishCallBack(err) { ...@@ -92,14 +98,16 @@ function publishCallBack(err) {
CommonEvent.publish("event", options, publishCallBack); CommonEvent.publish("event", options, publishCallBack);
``` ```
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
## CommonEvent.publishAsUser<sup>8+</sup>
publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void
Publishes a common event to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -131,14 +139,16 @@ let userId = 100; ...@@ -131,14 +139,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, publishAsUserCallBack); CommonEvent.publishAsUser("event", userId, publishAsUserCallBack);
``` ```
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
## CommonEvent.publishAsUser<sup>8+</sup>
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -178,14 +188,16 @@ let userId = 100; ...@@ -178,14 +188,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack); CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack);
``` ```
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
## CommonEvent.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
Creates a subscriber. This API uses an asynchronous callback to return the result. Creates a subscriber. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -220,14 +232,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) { ...@@ -220,14 +232,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
``` ```
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
## CommonEvent.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber> createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
Creates a subscriber. This API uses a promise to return the result. Creates a subscriber. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -260,14 +274,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => { ...@@ -260,14 +274,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
}); });
``` ```
## CommonEvent.subscribe<sup>(deprecated)</sup>
## CommonEvent.subscribe
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
Subscribes to common events. This API uses an asynchronous callback to return the result. Subscribes to common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagersubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -312,14 +328,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) { ...@@ -312,14 +328,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
``` ```
## CommonEvent.unsubscribe<sup>(deprecated)</sup>
## CommonEvent.unsubscribe
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
Unsubscribes from common events. This API uses an asynchronous callback to return the result. Unsubscribes from common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagerunsubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -370,10 +388,10 @@ function unsubscribeCallBack(err) { ...@@ -370,10 +388,10 @@ function unsubscribeCallBack(err) {
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, createCB); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
// Unsubscribe from the common event. // Unsubscribe from the common event.
CommonEvent.unsubscribe(subscriber, unsubscribeCB); CommonEvent.unsubscribe(subscriber, unsubscribeCallBack);
``` ```
## CommonEventSubscriber ## CommonEventSubscriber
......
...@@ -38,8 +38,7 @@ For details about the error codes, see [Event Error Codes](../errorcodes/errorco ...@@ -38,8 +38,7 @@ For details about the error codes, see [Event Error Codes](../errorcodes/errorco
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. | | 1500004 | not System services or System app. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -83,8 +82,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca ...@@ -83,8 +82,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
**Error codes** **Error codes**
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. | | 1500004 | not System services or System app. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -139,9 +137,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb ...@@ -139,9 +137,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb
**Error codes** **Error codes**
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 202 | not system app. | | 1500004 | not System services or System app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -193,9 +189,7 @@ Publishes a common event with given attributes to a specific user. This API uses ...@@ -193,9 +189,7 @@ Publishes a common event with given attributes to a specific user. This API uses
**Error codes** **Error codes**
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 202 | not system app. | | 1500004 | not System services or System app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -246,14 +240,6 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul ...@@ -246,14 +240,6 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
...@@ -304,14 +290,6 @@ Creates a subscriber. This API uses a promise to return the result. ...@@ -304,14 +290,6 @@ Creates a subscriber. This API uses a promise to return the result.
| --------------------------------------------------------- | ---------------- | | --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.| | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
```ts ```ts
...@@ -359,7 +337,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th ...@@ -359,7 +337,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. | | 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -431,7 +408,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur ...@@ -431,7 +408,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. | | 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -490,737 +466,6 @@ try { ...@@ -490,737 +466,6 @@ try {
} }
``` ```
## CommonEventSubscriber
### getCode
getCode(callback: AsyncCallback\<number>): void
Obtains the result code of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<number> | 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 |
| -------- | ----------------------------------- |
| 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. |
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code obtaining of an ordered common event.
function getCodeCallback(err, Code) {
if (err) {
console.error("getCode failed " + JSON.stringify(err));
} else {
console.info("getCode " + JSON.stringify(Code));
}
}
subscriber.getCode(getCodeCallback);
```
### getCode
getCode(): Promise\<number>
Obtains the result code of this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<number> | 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 |
| -------- | ----------------------------------- |
| 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. |
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getCode().then((Code) => {
console.info("getCode " + JSON.stringify(Code));
}).catch((err) => {
console.error("getCode failed " + JSON.stringify(err));
});
```
### setCode
setCode(code: number, callback: AsyncCallback\<void>): void
Sets the result code for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes | Result code of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code setting of an ordered common event.
function setCodeCallback(err) {
if (err) {
console.error("setCode failed " + JSON.stringify(err));
} else {
console.info("setCode");
}
}
subscriber.setCode(1, setCodeCallback);
```
### setCode
setCode(code: number): Promise\<void>
Sets the result code for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| code | number | Yes | Result code of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setCode(1).then(() => {
console.info("setCode");
}).catch((err) => {
console.error("setCode failed " + JSON.stringify(err));
});
```
### getData
getData(callback: AsyncCallback\<string>): void
Obtains the result data of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the result data.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result data obtaining of an ordered common event.
function getDataCallback(err, Data) {
if (err) {
console.error("getData failed " + JSON.stringify(err));
} else {
console.info("getData " + JSON.stringify(Data));
}
}
subscriber.getData(getDataCallback);
```
### getData
getData(): Promise\<string>
Obtains the result data of this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | ------------------ |
| Promise\<string> | Promise used to return the result data.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getData().then((Data) => {
console.info("getData " + JSON.stringify(Data));
}).catch((err) => {
console.error("getData failed " + JSON.stringify(err));
});
```
### setData
setData(data: string, callback: AsyncCallback\<void>): void
Sets the result data for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event
function setDataCallback(err) {
if (err) {
console.error("setData failed " + JSON.stringify(err));
} else {
console.info("setData");
}
}
subscriber.setData("publish_data_changed", setDataCallback);
```
### setData
setData(data: string): Promise\<void>
Sets the result data for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- |
| data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setData("publish_data_changed").then(() => {
console.info("setData");
}).catch((err) => {
console.error("setData failed " + JSON.stringify(err));
});
```
### setCodeAndData
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
Sets the result code and result data for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes | Result code of the common event. |
| data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code and result data setting of an ordered common event.
function setCodeDataCallback(err) {
if (err) {
console.error("setCodeAndData failed " + JSON.stringify(err));
} else {
console.info("setCodeDataCallback");
}
}
subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback);
```
### setCodeAndData
setCodeAndData(code: number, data: string): Promise\<void>
Sets the result code and result data for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- |
| code | number | Yes | Result code of the common event.|
| data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData");
}).catch((err) => {
console.info("setCodeAndData failed " + JSON.stringify(err));
});
```
### isOrderedCommonEvent
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is an ordered one.
function isOrderedCallback(err, isOrdered) {
if (err) {
console.error("isOrderedCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isOrdered " + JSON.stringify(isOrdered));
}
}
subscriber.isOrderedCommonEvent(isOrderedCallback);
```
### isOrderedCommonEvent
isOrderedCommonEvent(): Promise\<boolean>
Checks whether this common event is an ordered one. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | -------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => {
console.error("isOrdered failed " + JSON.stringify(err));
});
```
### isStickyCommonEvent
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is a sticky one.
function isStickyCallback(err, isSticky) {
if (err) {
console.error("isStickyCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isSticky " + JSON.stringify(isSticky));
}
}
subscriber.isStickyCommonEvent(isStickyCallback);
```
### isStickyCommonEvent
isStickyCommonEvent(): Promise\<boolean>
Checks whether this common event is a sticky one. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | -------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => {
console.error("isSticky failed " + JSON.stringify(err));
});
```
### abortCommonEvent
abortCommonEvent(callback: AsyncCallback\<void>): void
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for common event aborting.
function abortCallback(err) {
if (err) {
console.error("abortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("abortCommonEvent");
}
}
subscriber.abortCommonEvent(abortCallback);
```
### abortCommonEvent
abortCommonEvent(): Promise\<void>
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent");
}).catch((err) => {
console.error("abortCommonEvent failed " + JSON.stringify(err));
});
```
### clearAbortCommonEvent
clearAbortCommonEvent(callback: AsyncCallback\<void>): void
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for clearing the aborted state of the current common event.
function clearAbortCallback(err) {
if (err) {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("clearAbortCommonEvent");
}
}
subscriber.clearAbortCommonEvent(clearAbortCallback);
```
### clearAbortCommonEvent
clearAbortCommonEvent(): Promise\<void>
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent");
}).catch((err) => {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getAbortCommonEvent
getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is in the aborted state.
function getAbortCallback(err, AbortCommonEvent) {
if (err) {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("AbortCommonEvent " + AbortCommonEvent)
}
}
subscriber.getAbortCommonEvent(getAbortCallback);
```
### getAbortCommonEvent
getAbortCommonEvent(): Promise\<boolean>
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | ---------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent));
}).catch((err) => {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getSubscribeInfo
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
Obtains the subscriber information. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes | Callback used to return the subscriber information.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for subscriber information obtaining.
function getSubscribeInfoCallback(err, SubscribeInfo) {
if (err) {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
} else {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}
}
subscriber.getSubscribeInfo(getSubscribeInfoCallback);
```
### getSubscribeInfo
getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
Obtains the subscriber information. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ---------------------- |
| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise used to return the subscriber information.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getSubscribeInfo().then((SubscribeInfo) => {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}).catch((err) => {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
});
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback\<void\>): void
Finishes this ordered common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback returned after the ordered common event is finished.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing.
function finishCommonEventCallback(err) {
if (err) {
console.error("finishCommonEvent failed " + JSON.stringify(err));
} else {
console.info("FinishCommonEvent");
}
}
subscriber.finishCommonEvent(finishCommonEventCallback);
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(): Promise\<void\>
Finishes this ordered common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent");
}).catch((err) => {
console.error("finishCommonEvent failed " + JSON.stringify(err));
});
```
## CommonEventData ## CommonEventData
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
......
# CommonEventData # CommonEventData
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventPublishData # CommonEventPublishData
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventSubscribeInfo # CommonEventSubscribeInfo
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventSubscriber # CommonEventSubscriber
## getCode > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Usage
Before using the **CommonEventSubscriber** module, you must obtain a **subscriber** object by calling **CommonEvent.createSubscriber**.
```ts ```ts
getCode(callback: AsyncCallback<number>): void import CommonEvent from '@ohos.commonEvent';
let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
let subscribeInfo = {
events: ["event"]
};
// Callback for subscriber creation.
function createCB(err, commonEventSubscriber) {
if (err.code) {
console.error(`createSubscriber failed, code is ${err.code}`);
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
}
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, createCB);
``` ```
## getCode
getCode(callback: AsyncCallback\<number>): void
Obtains the code of this common event. This API uses an asynchronous callback to return the result. Obtains the code of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
...@@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to ...@@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code obtaining of an ordered common event. // Callback for result code obtaining of an ordered common event.
function getCodeCB(err, code) { function getCodeCB(err, code) {
if (err.code) { if (err.code) {
...@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB); ...@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB);
## getCode ## getCode
```ts getCode(): Promise\<number>
getCode(): Promise<number>
```
Obtains the code of this common event. This API uses a promise to return the result. Obtains the code of this common event. This API uses a promise to return the result.
...@@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res ...@@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getCode().then((code) => { subscriber.getCode().then((code) => {
console.info("getCode " + JSON.stringify(code)); console.info("getCode " + JSON.stringify(code));
}).catch((err) => { }).catch((err) => {
...@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => { ...@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => {
## setCode ## setCode
```ts setCode(code: number, callback: AsyncCallback\<void>): void
setCode(code: number, callback: AsyncCallback<void>): void
```
Sets the code for this common event. This API uses an asynchronous callback to return the result. Sets the code for this common event. This API uses an asynchronous callback to return the result.
...@@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r ...@@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code setting of an ordered common event. // Callback for result code setting of an ordered common event.
function setCodeCB(err) { function setCodeCB(err) {
if (err.code) { if (err.code) {
...@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB); ...@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB);
## setCode ## setCode
```ts setCode(code: number): Promise\<void>
setCode(code: number): Promise<void>
```
Sets the code for this common event. This API uses a promise to return the result. Sets the code for this common event. This API uses a promise to return the result.
...@@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul ...@@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCode(1).then(() => { subscriber.setCode(1).then(() => {
console.info("setCode"); console.info("setCode");
}).catch((err) => { }).catch((err) => {
...@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => { ...@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => {
## getData ## getData
```ts getData(callback: AsyncCallback\<string>): void
getData(callback: AsyncCallback<string>): void
```
Obtains the data of this common event. This API uses an asynchronous callback to return the result. Obtains the data of this common event. This API uses an asynchronous callback to return the result.
...@@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to ...@@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data obtaining of an ordered common event. // Callback for result data obtaining of an ordered common event.
function getDataCB(err, data) { function getDataCB(err, data) {
if (err.code) { if (err.code) {
...@@ -161,9 +172,7 @@ subscriber.getData(getDataCB); ...@@ -161,9 +172,7 @@ subscriber.getData(getDataCB);
## getData ## getData
```ts getData(): Promise\<string>
getData(): Promise<string>
```
Obtains the data of this common event. This API uses a promise to return the result. Obtains the data of this common event. This API uses a promise to return the result.
...@@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res ...@@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getData().then((data) => { subscriber.getData().then((data) => {
console.info("getData " + JSON.stringify(data)); console.info("getData " + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
...@@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r ...@@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setDataCB(err) { function setDataCB(err) {
if (err.code) { if (err.code) {
...@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB); ...@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB);
## setData ## setData
```ts setData(data: string): Promise\<void>
setData(data: string): Promise<void>
```
Sets the data for this common event. This API uses a promise to return the result. Sets the data for this common event. This API uses a promise to return the result.
...@@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul ...@@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setData("publish_data_changed").then(() => { subscriber.setData("publish_data_changed").then(() => {
console.info("setData"); console.info("setData");
}).catch((err) => { }).catch((err) => {
...@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => { ...@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => {
## setCodeAndData ## setCodeAndData
```ts setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
```
Sets the code and data for this common event. This API uses an asynchronous callback to return the result. Sets the code and data for this common event. This API uses an asynchronous callback to return the result.
...@@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call ...@@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for code and data setting of an ordered common event. // Callback for code and data setting of an ordered common event.
function setCodeDataCB(err) { function setCodeDataCB(err) {
if (err.code) { if (err.code) {
...@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB); ...@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB);
## setCodeAndData ## setCodeAndData
```ts setCodeAndData(code: number, data: string): Promise\<void>
setCodeAndData(code: number, data: string): Promise<void>
```
Sets the code and data for this common event. This API uses a promise to return the result. Sets the code and data for this common event. This API uses a promise to return the result.
...@@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return ...@@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => { subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData"); console.info("setCodeAndData");
}).catch((err) => { }).catch((err) => {
...@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => { ...@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
## isOrderedCommonEvent ## isOrderedCommonEvent
```ts isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result. Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
...@@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou ...@@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is an ordered one. // Callback for checking whether the current common event is an ordered one.
function isOrderedCB(err, isOrdered) { function isOrderedCB(err, isOrdered) {
if (err.code) { if (err.code) {
...@@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB); ...@@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB);
## isOrderedCommonEvent ## isOrderedCommonEvent
```ts isOrderedCommonEvent(): Promise\<boolean>
isOrderedCommonEvent(): Promise<boolean>
```
Checks whether this common event is an ordered one. This API uses a promise to return the result. Checks whether this common event is an ordered one. This API uses a promise to return the result.
...@@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r ...@@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.isOrderedCommonEvent().then((isOrdered) => { subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered)); console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => { }).catch((err) => {
...@@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => { ...@@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => {
## isStickyCommonEvent ## isStickyCommonEvent
```ts isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
isStickyCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result. Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
...@@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous ...@@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is a sticky one. // Callback for checking whether the current common event is a sticky one.
function isStickyCB(err, isSticky) { function isStickyCB(err, isSticky) {
if (err.code) { if (err.code) {
...@@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB); ...@@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB);
## isStickyCommonEvent ## isStickyCommonEvent
```ts isStickyCommonEvent(): Promise\<boolean>
isStickyCommonEvent(): Promise<boolean>
```
Checks whether this common event is a sticky one. This API uses a promise to return the result. Checks whether this common event is a sticky one. This API uses a promise to return the result.
...@@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret ...@@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => { subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky)); console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => { }).catch((err) => {
...@@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => { ...@@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => {
## abortCommonEvent ## abortCommonEvent
```ts abortCommonEvent(callback: AsyncCallback\<void>): void
abortCommonEvent(callback: AsyncCallback<void>): void
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n ...@@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for common event aborting. // Callback for common event aborting.
function abortCB(err) { function abortCB(err) {
if (err.code) { if (err.code) {
...@@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB); ...@@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB);
## abortCommonEvent ## abortCommonEvent
```ts abortCommonEvent(): Promise\<void>
abortCommonEvent(): Promise<void>
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n ...@@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.abortCommonEvent().then(() => { subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent"); console.info("abortCommonEvent");
}).catch((err) => { }).catch((err) => {
...@@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => { ...@@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => {
## clearAbortCommonEvent ## clearAbortCommonEvent
```ts clearAbortCommonEvent(callback: AsyncCallback\<void>): void
clearAbortCommonEvent(callback: AsyncCallback<void>): void
```
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or ...@@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for clearing the aborted state of the current common event. // Callback for clearing the aborted state of the current common event.
function clearAbortCB(err) { function clearAbortCB(err) {
if (err.code) { if (err.code) {
...@@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB); ...@@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB);
## clearAbortCommonEvent ## clearAbortCommonEvent
```ts clearAbortCommonEvent(): Promise\<void>
clearAbortCommonEvent(): Promise<void>
```
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result. Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or ...@@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.clearAbortCommonEvent().then(() => { subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent"); console.info("clearAbortCommonEvent");
}).catch((err) => { }).catch((err) => {
...@@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => { ...@@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => {
## getAbortCommonEvent ## getAbortCommonEvent
```ts getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
getAbortCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect ...@@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is in the aborted state. // Callback for checking whether the current common event is in the aborted state.
function getAbortCB(err, abortEvent) { function getAbortCB(err, abortEvent) {
if (err.code) { if (err.code) {
...@@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB); ...@@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB);
## getAbortCommonEvent ## getAbortCommonEvent
```ts getAbortCommonEvent(): Promise\<boolean>
getAbortCommonEvent(): Promise<boolean>
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result. Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect ...@@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getAbortCommonEvent().then((abortEvent) => { subscriber.getAbortCommonEvent().then((abortEvent) => {
console.info("abortCommonEvent " + JSON.stringify(abortEvent)); console.info("abortCommonEvent " + JSON.stringify(abortEvent));
}).catch((err) => { }).catch((err) => {
...@@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => { ...@@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => {
## getSubscribeInfo ## getSubscribeInfo
```ts getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
```
Obtains the subscriber information. This API uses an asynchronous callback to return the result. Obtains the subscriber information. This API uses an asynchronous callback to return the result.
...@@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re ...@@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for subscriber information obtaining. // Callback for subscriber information obtaining.
function getCB(err, subscribeInfo) { function getCB(err, subscribeInfo) {
if (err.code) { if (err.code) {
...@@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB); ...@@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB);
## getSubscribeInfo ## getSubscribeInfo
```ts getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
```
Obtains the subscriber information. This API uses a promise to return the result. Obtains the subscriber information. This API uses a promise to return the result.
...@@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result ...@@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getSubscribeInfo().then((subscribeInfo) => { subscriber.getSubscribeInfo().then((subscribeInfo) => {
console.info("subscribeInfo " + JSON.stringify(subscribeInfo)); console.info("subscribeInfo " + JSON.stringify(subscribeInfo));
}).catch((err) => { }).catch((err) => {
...@@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => { ...@@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => {
## finishCommonEvent<sup>9+</sup> ## finishCommonEvent<sup>9+</sup>
```ts finishCommonEvent(callback: AsyncCallback\<void>): void
finishCommonEvent(callback: AsyncCallback<void>): void
```
Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events ...@@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing. // Callback for ordered common event finishing.
function finishCB(err) { function finishCB(err) {
if (err.code) { if (err.code) {
console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`); console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
}
} }
subscriber.finishCommonEvent(finishCB); subscriber.finishCommonEvent(finishCB);
...@@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB); ...@@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB);
## finishCommonEvent<sup>9+</sup> ## finishCommonEvent<sup>9+</sup>
```ts finishCommonEvent(): Promise\<void>
finishCommonEvent(): Promise<void\>
```
Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result. Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events ...@@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent().then(() => { subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
}).catch((err) => { }).catch((err) => {
......
...@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no ...@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | | --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | Yes | Yes | Button title. | | title | string | No | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.| | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. | | extras | { [key: string]: any } | No | No | Extra information of the button. |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | Yes | Yes | User input object. | | userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | No | No | User input object. |
...@@ -10,7 +10,7 @@ Provides the bundle information of an application. ...@@ -10,7 +10,7 @@ Provides the bundle information of an application.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Mandatory| Description | | Name | Type | Read-only| Mandatory| Description |
| ------ | ------ |---- | ------ | | ------ | ------ | ---- | ---- | ------ |
| bundle | string | Yes| Bundle information of the application.| | bundle | string | No | Yes| Bundle information of the application.|
| uid | number | No| User ID.| | uid | number | No | No| User ID.|
...@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content. ...@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ | | ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | Yes | Yes | Notification content type. | | contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | No | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. | | normal | [NotificationBasicContent](#notificationbasiccontent) | No | No | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.| | longText | [NotificationLongTextContent](#notificationlongtextcontent) | No | No | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. | | multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | No | No | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. | | picture | [NotificationPictureContent](#notificationpicturecontent) | No | No | Picture-attached. |
## NotificationBasicContent ## NotificationBasicContent
...@@ -22,11 +22,11 @@ Describes the normal text notification. ...@@ -22,11 +22,11 @@ Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | ---- | ---------------------------------- | | -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
## NotificationLongTextContent ## NotificationLongTextContent
...@@ -35,14 +35,14 @@ Describes the long text notification. ...@@ -35,14 +35,14 @@ Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | --- | -------------------------------- | | -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| longText | string | Yes | Yes | Long text of the notification. | | longText | string | No | Yes | Long text of the notification. |
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification. |
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | | expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent ## NotificationMultiLineContent
...@@ -53,12 +53,12 @@ Describes the multi-line text notification. ...@@ -53,12 +53,12 @@ Describes the multi-line text notification.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------------- | --------------- | --- | --- | -------------------------------- | | -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification.|
| longTitle | string | Yes | Yes | Title of the notification in the expanded state. | | longTitle | string | No | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. | | lines | Array\<string\> | No | Yes | Multi-line text of the notification. |
## NotificationPictureContent ## NotificationPictureContent
...@@ -69,9 +69,9 @@ Describes the picture-attached notification. ...@@ -69,9 +69,9 @@ Describes the picture-attached notification.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- | | -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | | expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. | | picture | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Yes | Picture attached to the notification. |
...@@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance. ...@@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | | ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. | | soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. | | vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. |
......
...@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request. ...@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | | --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | Yes | Yes | Notification content. | | content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | No | Yes | Notification content. |
| id | number | Yes | Yes | Notification ID. | | id | number | No | No | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. | | slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | No | Notification slot type. |
| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. | | isOngoing | boolean | No | No | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. | | isUnremovable | boolean | No | No | Whether the notification can be removed. |
| deliveryTime | number | Yes | Yes | Time when the notification is sent. | | deliveryTime | number | No | No | Time when the notification is sent. |
| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. | | tapDismissed | boolean | No | No | Whether the notification is automatically cleared. |
| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. | | autoDeletedTime | number | No | No | Time when the notification is automatically cleared. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked.| | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected after being clicked.|
| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. | | extraInfo | {[key: string]: any} | No | No | Extended parameters. |
| color | number | Yes | Yes | Background color of the notification. Not supported currently.| | color | number | No | No | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.| | colorEnabled | boolean | No | No | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.| | isAlertOnce | boolean | No | No | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. | | isStopwatch | boolean | No | No | Whether to display the stopwatch. |
| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. | | isCountDown | boolean | No | No | Whether to display the countdown time. |
| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. | | isFloatingIcon | boolean | No | No | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | Yes | Yes | Notification label. | | label | string | No | No | Notification label. |
| badgeIconStyle | number | Yes | Yes | Notification badge type. | | badgeIconStyle | number | No | No | Notification badge type. Not supported currently. |
| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. | | showDeliveryTime | boolean | No | No | Whether to display the time when the notification is delivered. |
| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | Yes | Yes | Buttons in the notification. Up to three buttons are allowed. | | actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | No | No | Buttons in the notification. Up to three buttons are allowed. |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.| | smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | No | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.| | largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | No | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. | | creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. |
| creatorUid<sup>8+<sup> | number | Yes | No | UID used for creating the notification. | | creatorUid<sup>8+<sup> | number | Yes | No | UID used for creating the notification. |
| creatorPid | number | Yes | No | PID used for creating the notification. | | creatorPid | number | Yes | No | PID used for creating the notification. |
| creatorUserId| number | Yes | No | ID of the user who creates the notification. | | creatorUserId | number | Yes | No | ID of the user who creates the notification. |
| hashCode | string | Yes | No | Unique ID of the notification. | | hashCode | string | Yes | No | Unique ID of the notification. |
| classification | string | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. | | classification | string | No | No | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| groupName<sup>8+<sup> | string | Yes | Yes | Notification group name. | | groupName<sup>8+<sup> | string | No | No | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. | | template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | No | Notification template. |
| isRemoveAllowed<sup>8+<sup> | boolean | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. | | isRemoveAllowed<sup>8+<sup> | boolean | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| source<sup>8+<sup> | number | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. | | source<sup>8+<sup> | number | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | Yes | Yes | Distributed notification options. | | distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | No | No | Distributed notification options. |
| deviceId<sup>8+<sup> | string | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. | | deviceId<sup>8+<sup> | string | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | Yes | No | Notification flags. | | notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | Yes | No | Notification flags. |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. | | removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | number | Yes | Yes | Number of notifications displayed on the application icon. | | badgeNumber<sup>9+<sup> | number | No | No | Number of notifications displayed on the application icon. |
## DistributedOptions ## DistributedOptions
...@@ -55,9 +55,9 @@ Describes distributed notification options. ...@@ -55,9 +55,9 @@ Describes distributed notification options.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed<sup>8+<sup> | boolean | Yes | Yes | Whether the notification is a distributed notification. | | isDistributed<sup>8+<sup> | boolean | No | No | Whether the notification is a distributed notification. |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices to which the notification can be synchronized. | | supportDisplayDevices<sup>8+<sup> | Array\<string> | No | No | List of the devices to which the notification can be synchronized. |
| supportOperateDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices on which the notification can be opened. | | supportOperateDevices<sup>8+<sup> | Array\<string> | No | No | List of the devices on which the notification can be opened. |
| remindType<sup>8+<sup> | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. | | remindType<sup>8+<sup> | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. |
...@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot. ...@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | | -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. | | type | [SlotType](js-apis-notificationManager.md#slottype) | No | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.| | level | number | No | No | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.|
| desc | string | Yes | Yes | Notification slot description. | | desc | string | No | No | Notification slot description. |
| badgeFlag | boolean | Yes | Yes | Whether to display the badge. | | badgeFlag | boolean | No | No | Whether to display the badge. |
| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. | | bypassDnd | boolean | No | No | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. | | lockscreenVisibility | number | No | No | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | Yes | Yes | Whether to enable vibration for the notification. | | vibrationEnabled | boolean | No | No | Whether to enable vibration for the notification. |
| sound | string | Yes | Yes | Notification alert tone. | | sound | string | No | No | Notification alert tone. |
| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. | | lightEnabled | boolean | No | No | Whether the indicator blinks for the notification. |
| lightColor | number | Yes | Yes | Indicator color of the notification. | | lightColor | number | No | No | Indicator color of the notification. |
| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. | | vibrationValues | Array\<number\> | No | No | Vibration mode of the notification. |
| enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. | | enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. |
# NotificationSorting
Provides sorting information of active notifications.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc | string | Yes | Yes | Description of the notification slot. |
# NotificationSortingMap
Provides sorting information of active notifications in all subscribed notifications.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| sortings | { [key: string]: [NotificationSorting](js-apis-inner-notification-notificationSorting.md) } | Yes | Yes | Array of notification sorting information.|
| sortedHashCode | Array\<string> | Yes | Yes | Hash codes for notification sorting.|
# NotificationSubscribeInfo
Provides the information about the publisher for notification subscription.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| bundleNames | Array\<string> | No | No | Bundle names of the applications whose notifications are to be subscribed to. |
| userId | number | No | No | User ID. |
...@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template. ...@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description | | Name| Type | Read-only| Mandatory| Description |
| ---- | ---------------------- | ---- | ---- | ---------- | | ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.| | name | string | No | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.| | data | {[key:string]: Object} | No | Yes | Template data.|
...@@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input. ...@@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------- | ------ | --- | ---- | ----------------------------- | | -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.| | inputKey | string | No | Yes | Key to identify the user input.|
...@@ -586,7 +586,7 @@ Notification.getSlot(slotType).then((data) => { ...@@ -586,7 +586,7 @@ Notification.getSlot(slotType).then((data) => {
## Notification.getSlots ## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains all notification slots. This API uses an asynchronous callback to return the result. Obtains all notification slots. This API uses an asynchronous callback to return the result.
...@@ -596,7 +596,7 @@ Obtains all notification slots. This API uses an asynchronous callback to return ...@@ -596,7 +596,7 @@ Obtains all notification slots. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | -------------------- | | -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1364,7 +1364,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1364,7 +1364,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
...@@ -1379,7 +1379,7 @@ Obtains the notification slots of a specified application. This API uses an asyn ...@@ -1379,7 +1379,7 @@ Obtains the notification slots of a specified application. This API uses an asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1401,7 +1401,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ...@@ -1401,7 +1401,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
Obtains the notification slots of a specified application. This API uses a promise to return the result. Obtains the notification slots of a specified application. This API uses a promise to return the result.
...@@ -1421,7 +1421,7 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1421,7 +1421,7 @@ Obtains the notification slots of a specified application. This API uses a promi
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.| | Promise\<Array\<[NotificationSlot](#notificationslot)>> | Promise used to return the result.|
**Example** **Example**
...@@ -1823,7 +1823,7 @@ Notification.removeAll(userId).then(() => { ...@@ -1823,7 +1823,7 @@ Notification.removeAll(userId).then(() => {
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains all active notifications. This API uses an asynchronous callback to return the result. Obtains all active notifications. This API uses an asynchronous callback to return the result.
...@@ -1837,7 +1837,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu ...@@ -1837,7 +1837,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationRequest](#notificationrequest)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1857,7 +1857,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ...@@ -1857,7 +1857,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)>>
Obtains all active notifications. This API uses a promise to return the result. Obtains all active notifications. This API uses a promise to return the result.
...@@ -1871,7 +1871,7 @@ Obtains all active notifications. This API uses a promise to return the result. ...@@ -1871,7 +1871,7 @@ Obtains all active notifications. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.| | Promise\<Array\<[NotificationRequest](#notificationrequest)>> | Promise used to return the result.|
**Example** **Example**
...@@ -2903,476 +2903,6 @@ Notification.getDeviceRemindType().then((data) => { ...@@ -2903,476 +2903,6 @@ Notification.getDeviceRemindType().then((data) => {
}); });
``` ```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Publishes an agent-powered notification. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**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 | 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**
```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"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId, callback);
```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
Publishes a notification through the reminder agent. This API uses a promise to return the result.
**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 | 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. |
**Example**
```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"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle success");
});
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result.
**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.
**Parameters**
| 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.|
**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;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
Cancels a notification published by the reminder agent. 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, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| 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**
```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;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success");
});
```
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
Sets the enabled status of a notification slot type for a specified application. 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 |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| enable | boolean | Yes | Whether to enable notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
// enableNotificationSlot
function enableSlotCallback(err) {
if (err.code) {
console.info("enableNotificationSlot failed " + JSON.stringify(err));
} else {
console.info("enableNotificationSlot success");
}
};
Notification.enableNotificationSlot(
{ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,
true,
enableSlotCallback);
```
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void>
Sets the enabled status of a notification slot type for a specified application. 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 |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
| enable | boolean | Yes | Whether to enable notification. |
**Example**
```js
// enableNotificationSlot
Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => {
console.info("enableNotificationSlot success");
});
```
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
Checks whether a specified notification slot type is enabled for a specified application. 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 |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example**
```js
// isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
if (err.code) {
console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
} else {
console.info("isNotificationSlotEnabled success");
}
};
Notification.isNotificationSlotEnabled(
{ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,
getEnableSlotCallback);
```
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
Checks whether a specified notification slot type is enabled for a specified application. 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 |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
**Return value**
| Type | Description |
| ------------------ | ------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
**Example**
```js
// isNotificationSlotEnabled
Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
```
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
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.
**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. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**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.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| enable | boolean | Yes | Whether the feature is enabled. |
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let userId = 100;
let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => {
console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
});
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example**
```js
let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(err, data) {
if (err) {
console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
} else {
console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
}
}
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
**Return value**
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
**Example**
```js
let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
});
```
## NotificationSubscriber ## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe). Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).
...@@ -4111,5 +3641,5 @@ Provides the notification user input. ...@@ -4111,5 +3641,5 @@ Provides the notification user input.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | | CLICK_REASON_REMOVE<sup>9+</sup> | 1 | The notification is removed after a click on it. |
| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | | CANCEL_REASON_REMOVE<sup>9+</sup> | 2 | The notification is removed by the user. |
...@@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -89,8 +88,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -89,8 +88,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -208,8 +203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -208,8 +203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -263,7 +256,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -263,7 +256,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -343,7 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -343,7 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -379,7 +369,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -379,7 +369,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -420,7 +409,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -420,7 +409,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -460,9 +448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -460,9 +448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -511,9 +496,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -511,9 +496,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -553,7 +535,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -553,7 +535,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -594,7 +575,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -594,7 +575,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -634,9 +614,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -634,9 +614,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -689,9 +666,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -689,9 +666,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -735,7 +709,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -735,7 +709,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -783,7 +756,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -783,7 +756,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -801,7 +773,7 @@ Notification.getSlot(slotType).then((data) => { ...@@ -801,7 +773,7 @@ Notification.getSlot(slotType).then((data) => {
## Notification.getSlots ## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains all notification slots of this application. This API uses an asynchronous callback to return the result. Obtains all notification slots of this application. This API uses an asynchronous callback to return the result.
...@@ -819,7 +791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -819,7 +791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -842,7 +813,7 @@ Notification.getSlots(getSlotsCallback); ...@@ -842,7 +813,7 @@ Notification.getSlots(getSlotsCallback);
## Notification.getSlots ## Notification.getSlots
getSlots(): Promise\<Array\<NotificationSlot\>> getSlots(): Promise\<Array\<NotificationSlot>>
Obtains all notification slots of this application. This API uses a promise to return the result. Obtains all notification slots of this application. This API uses a promise to return the result.
...@@ -860,7 +831,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -860,7 +831,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -896,7 +866,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -896,7 +866,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -938,7 +907,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -938,7 +907,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -974,7 +942,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -974,7 +942,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1008,7 +975,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1008,7 +975,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1049,9 +1015,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1049,9 +1015,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1100,9 +1063,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1100,9 +1063,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1146,9 +1106,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1146,9 +1106,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1202,9 +1159,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1202,9 +1159,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1247,9 +1201,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1247,9 +1201,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1282,11 +1233,93 @@ Checks whether notification is enabled for the current application. This API use ...@@ -1282,11 +1233,93 @@ Checks whether notification is enabled for the current application. This API use
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**Example**
```ts
notificationManager.isNotificationEnabled().then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
Checks whether notification is enabled for a specified user. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ |
| userId | number | Yes | User ID.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
| 1600008 | The user is not exist. |
**Example**
```ts
function isNotificationEnabledCallback(err, data) {
if (err) {
console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("isNotificationEnabled success");
}
}
let userId = 1;
notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number): Promise\<boolean\>
Checks whether notification is enabled for a specified user. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.| | userId | number | Yes | User ID.|
**Return value** **Return value**
...@@ -1300,18 +1333,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1300,18 +1333,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 17700001 | The specified bundle name was not found. | | 1600008 | The user is not exist.. |
**Example** **Example**
```js ```ts
Notification.isNotificationEnabled().then((data) => { let userId = 1;
notificationManager.isNotificationEnabled(userId).then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1344,9 +1376,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1344,9 +1376,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1395,9 +1424,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1395,9 +1424,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1441,9 +1467,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1441,9 +1467,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1497,9 +1520,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1497,9 +1520,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1542,9 +1562,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1542,9 +1562,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1598,9 +1615,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1598,9 +1615,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1624,7 +1638,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1624,7 +1638,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
...@@ -1647,9 +1661,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1647,9 +1661,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1695,7 +1706,7 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1695,7 +1706,7 @@ Obtains the notification slots of a specified application. This API uses a promi
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | Promise used to return the result.| | Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | Promise used to return the result.|
**Error codes** **Error codes**
...@@ -1703,9 +1714,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1703,9 +1714,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1749,9 +1757,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1749,9 +1757,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1805,9 +1810,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1805,9 +1810,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1829,7 +1831,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => { ...@@ -1829,7 +1831,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => {
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains all active notifications. This API uses an asynchronous callback to return the result. Obtains all active notifications. This API uses an asynchronous callback to return the result.
...@@ -1851,9 +1853,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1851,9 +1853,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1898,9 +1897,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1898,9 +1897,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1935,7 +1931,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1935,7 +1931,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1976,7 +1971,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1976,7 +1971,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1993,7 +1987,7 @@ Notification.getActiveNotificationCount().then((data) => { ...@@ -1993,7 +1987,7 @@ Notification.getActiveNotificationCount().then((data) => {
## Notification.getActiveNotifications ## Notification.getActiveNotifications
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains active notifications of this application. This API uses an asynchronous callback to return the result. Obtains active notifications of this application. This API uses an asynchronous callback to return the result.
...@@ -2003,7 +1997,7 @@ Obtains active notifications of this application. This API uses an asynchronous ...@@ -2003,7 +1997,7 @@ Obtains active notifications of this application. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -2011,7 +2005,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2011,7 +2005,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2052,7 +2045,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2052,7 +2045,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2088,7 +2080,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2088,7 +2080,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2104,7 +2095,7 @@ function cancelGroupCallback(err) { ...@@ -2104,7 +2095,7 @@ function cancelGroupCallback(err) {
} }
} }
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName, cancelGroupCallback); Notification.cancelGroup(groupName, cancelGroupCallback);
``` ```
...@@ -2131,7 +2122,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2131,7 +2122,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2173,9 +2163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2173,9 +2163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2225,9 +2212,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2225,9 +2212,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2270,9 +2254,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2270,9 +2254,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2323,9 +2304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2323,9 +2304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2370,9 +2348,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2370,9 +2348,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2427,9 +2402,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2427,9 +2402,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2476,9 +2448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2476,9 +2448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2523,9 +2492,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2523,9 +2492,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2564,9 +2530,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2564,9 +2530,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2620,9 +2583,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2620,9 +2583,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2663,9 +2623,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2663,9 +2623,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2710,9 +2667,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2710,9 +2667,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2748,11 +2702,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2748,11 +2702,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**Example** **Example**
...@@ -2797,11 +2749,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2797,11 +2749,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**Example** **Example**
...@@ -2835,7 +2785,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2835,7 +2785,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2870,7 +2819,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2870,7 +2819,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2910,9 +2858,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2910,9 +2858,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2960,9 +2905,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2960,9 +2905,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2999,7 +2941,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2999,7 +2941,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3041,7 +2982,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3041,7 +2982,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3083,9 +3023,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3083,9 +3023,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3139,9 +3076,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3139,9 +3076,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3187,9 +3121,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3187,9 +3121,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3246,9 +3177,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3246,9 +3177,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3292,9 +3220,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3292,9 +3220,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3339,9 +3264,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3339,9 +3264,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3382,9 +3304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3382,9 +3304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3451,9 +3370,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3451,9 +3370,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3516,9 +3432,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3516,9 +3432,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3572,9 +3485,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3572,9 +3485,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3621,9 +3531,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3621,9 +3531,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3674,9 +3581,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3674,9 +3581,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3720,9 +3624,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3720,9 +3624,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3777,9 +3678,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3777,9 +3678,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3822,9 +3720,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3822,9 +3720,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3879,9 +3774,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3879,9 +3774,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3926,9 +3818,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3926,9 +3818,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3981,9 +3870,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3981,9 +3870,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
......
...@@ -40,9 +40,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -40,9 +40,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -95,9 +92,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -95,9 +92,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -148,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -148,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -196,9 +187,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -196,9 +187,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -246,9 +234,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -246,9 +234,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -294,9 +279,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -294,9 +279,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -352,9 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -352,9 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -371,7 +350,7 @@ let notificationKey = { ...@@ -371,7 +350,7 @@ let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
}; };
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(bundle, notificationKey, reason).then(() => { notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
...@@ -393,7 +372,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu ...@@ -393,7 +372,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | Yes | Unique notification ID. It is the 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-notification.md#onconsume) callback.|
| reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -403,9 +382,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -403,9 +382,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -423,7 +399,7 @@ function removeCallback(err) { ...@@ -423,7 +399,7 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
notificationSubscribe.remove(hashCode, reason, removeCallback); notificationSubscribe.remove(hashCode, reason, removeCallback);
``` ```
...@@ -452,9 +428,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -452,9 +428,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -495,9 +468,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -495,9 +468,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -516,7 +486,7 @@ function removeAllCallback(err) { ...@@ -516,7 +486,7 @@ function removeAllCallback(err) {
let bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
}; };
NotificationSubscribe.removeAll(bundle, removeAllCallback); notificationSubscribe.removeAll(bundle, removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
...@@ -543,9 +513,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -543,9 +513,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -588,9 +555,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -588,9 +555,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -630,9 +594,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -630,9 +594,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -678,9 +639,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -678,9 +639,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -702,319 +660,6 @@ let userId = 1; ...@@ -702,319 +660,6 @@ let userId = 1;
notificationSubscribe.removeAll(userId, removeAllCallback); 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.
**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);
```
## RemoveReason ## RemoveReason
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
......
...@@ -14,13 +14,6 @@ The **request** module provides applications with basic upload, download, and ba ...@@ -14,13 +14,6 @@ The **request** module provides applications with basic upload, download, and ba
import request from '@ohos.request'; import request from '@ohos.request';
``` ```
## Constraints
Only HTTP requests are supported. HTTPS requests are not supported.
The download server must support the HTTP HEAD method so that the size of the data to download can be obtained through **Content-length**. Otherwise, the download task fails. If this is the case, you can check the failure cause through [on('fail')<sup>7+</sup>](#onfail7).
## Constants ## Constants
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -36,7 +29,7 @@ You can set **networkType** in [DownloadConfig](#downloadconfig) to specify the ...@@ -36,7 +29,7 @@ You can set **networkType** in [DownloadConfig](#downloadconfig) to specify the
| NETWORK_WIFI | number | 0x00010000 | Whether download is allowed on a WLAN.| | NETWORK_WIFI | number | 0x00010000 | Whether download is allowed on a WLAN.|
### Download Error Codes ### Download Error Codes
The table below lists the error codes that may be returned by [on('fail')<sup>7+</sup>](#onfail7)/[off('fail')<sup>7+</sup>](#offfail7)/[getTaskInfo<sup>9+</sup>](#gettaskinfo9). The table below lists the values of **err** in the callback of [on('fail')<sup>7+</sup>](#onfail7) and the values of **failedReason** returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9).
| Name| Type| Value| Description| | Name| Type| Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -54,7 +47,7 @@ The table below lists the error codes that may be returned by [on('fail')<sup>7+ ...@@ -54,7 +47,7 @@ The table below lists the error codes that may be returned by [on('fail')<sup>7+
### Causes of Download Pause ### Causes of Download Pause
The table below lists the causes of download pause that may be returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9). The table below lists the values of **pausedReason** returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9).
| Name| Type| Value| Description| | Name| Type| Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -65,7 +58,7 @@ The table below lists the causes of download pause that may be returned by [getT ...@@ -65,7 +58,7 @@ The table below lists the causes of download pause that may be returned by [getT
| PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.| | PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.|
### Download Task Status Codes ### Download Task Status Codes
The table below lists the download task status codes that may be returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9). The table below lists the values of **status** returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9).
| Name| Type| Value| Description| | Name| Type| Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -105,7 +98,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -105,7 +98,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
**Example** **Example**
...@@ -153,7 +146,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -153,7 +146,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
**Example** **Example**
...@@ -279,7 +272,7 @@ Implements file uploads. Before using any APIs of this class, you must obtain an ...@@ -279,7 +272,7 @@ Implements file uploads. Before using any APIs of this class, you must obtain an
on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void
Subscribes to an upload event. This API uses an asynchronous callback to return the result. Subscribes to upload progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -296,16 +289,16 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -296,16 +289,16 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bits. | | uploadedSize | number | Yes| Size of the uploaded files, in bits.|
| totalSize | number | Yes| Total size of the files to upload, in bits. | | totalSize | number | Yes| Total size of the files to upload, in bits.|
**Example** **Example**
```js ```js
uploadTask.on('progress', function callback(uploadedSize, totalSize) { let upProgressCallback = (uploadedSize, totalSize) => {
console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
} };
); uploadTask.on('progress', upProgressCallback);
``` ```
...@@ -313,7 +306,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -313,7 +306,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
on(type: 'headerReceive', callback: (header: object) =&gt; void): void on(type: 'headerReceive', callback: (header: object) =&gt; void): void
Subscribes to an upload event. This API uses an asynchronous callback to return the result. Subscribes to HTTP header events for an upload task. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -335,10 +328,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -335,10 +328,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
**Example** **Example**
```js ```js
uploadTask.on('headerReceive', function callback(headers){ let headerCallback = (headers) => {
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} };
); uploadTask.on('headerReceive', headerCallback);
``` ```
...@@ -346,7 +339,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -346,7 +339,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
on(type:'complete' | 'fail', callback: Callback&lt;Array&lt;TaskState&gt;&gt;): void; on(type:'complete' | 'fail', callback: Callback&lt;Array&lt;TaskState&gt;&gt;): void;
Subscribes to an upload event. This API uses an asynchronous callback to return the result. Subscribes to upload completion or failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -368,19 +361,19 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -368,19 +361,19 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
**Example** **Example**
```js ```js
uploadTask.on('complete', function callback(taskStates) { let upCompleteCallback = (taskStates) => {
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i])); console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i]));
} }
} };
); uploadTask.on('complete', upCompleteCallback);
uploadTask.on('fail', function callback(taskStates) { let upFailCallback = (taskStates) => {
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnFail taskState:" + JSON.stringify(taskStates[i])); console.info("upOnFail taskState:" + JSON.stringify(taskStates[i]));
} }
} };
); uploadTask.on('fail', upFailCallback);
``` ```
...@@ -388,7 +381,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -388,7 +381,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&gt; void): void off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&gt; void): void
Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. Unsubscribes from upload progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -399,22 +392,15 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -399,22 +392,15 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback for the upload progress event.| | callback | function | No| Callback used to return the result.<br>**uploadedSize**: size of the uploaded files, in bits.<br>**totalSize**: Total size of the files to upload, in bits. |
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bits. |
| totalSize | number | Yes| Total size of the files to upload, in bits. |
**Example** **Example**
```js ```js
uploadTask.off('progress', function callback(uploadedSize, totalSize) { let upProgressCallback = (uploadedSize, totalSize) => {
console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); console.info('Upload delete progress notification.' + 'totalSize:' + totalSize + 'uploadedSize:' + uploadedSize);
} };
); uploadTask.off('progress', upProgressCallback);
``` ```
...@@ -422,7 +408,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -422,7 +408,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
off(type: 'headerReceive', callback?: (header: object) =&gt; void): void off(type: 'headerReceive', callback?: (header: object) =&gt; void): void
Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. Unsubscribes from HTTP header events for an upload task. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -433,28 +419,22 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -433,28 +419,22 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).|
| callback | function | No| Callback for the HTTP Response Header event.| | callback | function | No| Callback used to return the result.<br>**header**: HTTP response header.|
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| header | object | Yes| HTTP Response Header.|
**Example** **Example**
```js ```js
uploadTask.off('headerReceive', function callback(headers) { let headerCallback = (header) => {
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info(`Upload delete headerReceive notification. header: ${JSON.stringify(header)}`);
} };
); uploadTask.off('headerReceive', headerCallback);
``` ```
### off('complete' | 'fail')<sup>9+</sup> ### off('complete' | 'fail')<sup>9+</sup>
off(type:'complete' | 'fail', callback?: Callback&lt;Array&lt;TaskState&gt;&gt;): void; off(type:'complete' | 'fail', callback?: Callback&lt;Array&lt;TaskState&gt;&gt;): void;
Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. Unsubscribes from upload completion or failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -465,30 +445,26 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -465,30 +445,26 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| | type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback&lt;Array&lt;TaskState&gt;&gt; | No| Callback used to return the result.| | callback | Callback&lt;Array&lt;TaskState&gt;&gt; | No| Callback used to return the result.<br>**taskstates**: upload task result.|
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| taskstates | Array&lt;[TaskState](#taskstate9)&gt; | Yes| Upload result.|
**Example** **Example**
```js ```js
uploadTask.off('complete', function callback(taskStates) { let upCompleteCallback = (taskStates) => {
console.info('Upload delete complete notification.');
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i])); console.info('taskState:' + JSON.stringify(taskStates[i]));
} }
} };
); uploadTask.off('complete', upCompleteCallback);
uploadTask.off('fail', function callback(taskStates) { let upFailCallback = (taskStates) => {
console.info('Upload delete fail notification.');
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnFail taskState:" + JSON.stringify(taskStates[i])); console.info('taskState:' + JSON.stringify(taskStates[i]));
}
} }
); };
uploadTask.off('fail', upFailCallback);
``` ```
### delete<sup>9+</sup> ### delete<sup>9+</sup>
...@@ -709,9 +685,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -709,9 +685,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400001 | File operation error. | | 13400001 | file operation error. |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
| 13400003 | Task manager service error. | | 13400003 | task manager service error. |
**Example** **Example**
...@@ -753,9 +729,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -753,9 +729,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400001 | File operation error. | | 13400001 | file operation error. |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
| 13400003 | Task manager service error. | | 13400003 | task manager service error. |
**Example** **Example**
...@@ -861,7 +837,7 @@ Implements file downloads. ...@@ -861,7 +837,7 @@ Implements file downloads.
on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; void): void
Subscribes to a download event. This API uses an asynchronous callback to return the result. Subscribes to download progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -872,22 +848,22 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -872,22 +848,22 @@ Subscribes to a download event. This API uses an asynchronous callback to return
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| callback | function | Yes| Callback for the download progress event.| | callback | function | Yes| Callback used to return the result.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bits.| | receivedSize | number | Yes| Size of the downloaded files, in bits. |
| totalSize | number | Yes| Total size of the files to download, in bits.| | totalSize | number | Yes| Total size of the files to download, in bits. |
**Example** **Example**
```js ```js
downloadTask.on('progress', function download_callback(receivedSize, totalSize) { let progresCallback = (receivedSize, totalSize) => {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
} };
); downloadTask.on('progress', progresCallback);
``` ```
...@@ -895,7 +871,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -895,7 +871,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return
off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt; void): void off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt; void): void
Unsubscribes from a download event. This API uses an asynchronous callback to return the result. Unsubscribes from download progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -906,22 +882,15 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -906,22 +882,15 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).|
| callback | function | No| Callback for the download progress event.| | callback | function | No| Callback used to return the result.<br>**receivedSize**: size of the downloaded files.<br>**totalSize**: total size of the files to download.|
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bits.|
| totalSize | number | Yes| Total size of the files to download, in bits.|
**Example** **Example**
```js ```js
downloadTask .off('progress', function download_callback(receivedSize, totalSize) { let progresCallback = (receivedSize, totalSize) => {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); console.info('Download delete progress notification.' + 'receivedSize:' + receivedSize + 'totalSize:' + totalSize);
} };
); downloadTask.off('progress', progresCallback);
``` ```
...@@ -929,7 +898,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -929,7 +898,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void
Subscribes to a download event. This API uses an asynchronous callback to return the result. Subscribes to download events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -945,10 +914,20 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -945,10 +914,20 @@ Subscribes to a download event. This API uses an asynchronous callback to return
**Example** **Example**
```js ```js
downloadTask.on('complete', function callback() { let completeCallback = () => {
console.info('Download task completed.'); console.info('Download task completed.');
} };
); downloadTask.on('complete', completeCallback);
let pauseCallback = () => {
console.info('Download task pause.');
};
downloadTask.on('pause', pauseCallback);
let removeCallback = () => {
console.info('Download task remove.');
};
downloadTask.on('remove', removeCallback);
``` ```
...@@ -956,7 +935,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -956,7 +935,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return
off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void
Unsubscribes from a download event. This API uses an asynchronous callback to return the result. Unsubscribes from download events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -972,10 +951,20 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -972,10 +951,20 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
**Example** **Example**
```js ```js
downloadTask.off('complete', function callback() { let completeCallback = () => {
console.info('Download task completed.'); console.info('Download delete complete notification.');
} };
); downloadTask.off('complete', completeCallback);
let pauseCallback = () => {
console.info('Download delete pause notification.');
};
downloadTask.off('pause', pauseCallback);
let removeCallback = () => {
console.info('Download delete remove notification.');
};
downloadTask.off('remove', removeCallback);
``` ```
...@@ -983,7 +972,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -983,7 +972,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
on(type: 'fail', callback: (err: number) =&gt; void): void on(type: 'fail', callback: (err: number) =&gt; void): void
Subscribes to the download task failure event. This API uses an asynchronous callback to return the result. Subscribes to download failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -1005,10 +994,10 @@ Subscribes to the download task failure event. This API uses an asynchronous cal ...@@ -1005,10 +994,10 @@ Subscribes to the download task failure event. This API uses an asynchronous cal
**Example** **Example**
```js ```js
downloadTask.on('fail', function callBack(err) { let failCallback = (err) => {
console.info('Download task failed. Cause:' + err); console.info('Download task failed. Cause:' + err);
} };
); downloadTask.on('fail', failCallback);
``` ```
...@@ -1016,7 +1005,7 @@ Subscribes to the download task failure event. This API uses an asynchronous cal ...@@ -1016,7 +1005,7 @@ Subscribes to the download task failure event. This API uses an asynchronous cal
off(type: 'fail', callback?: (err: number) =&gt; void): void off(type: 'fail', callback?: (err: number) =&gt; void): void
Unsubscribes from the download task failure event. This API uses an asynchronous callback to return the result. Unsubscribes from download failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -1027,21 +1016,15 @@ Unsubscribes from the download task failure event. This API uses an asynchronous ...@@ -1027,21 +1016,15 @@ Unsubscribes from the download task failure event. This API uses an asynchronous
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).|
| callback | function | No| Callback for the download task failure event.| | callback | function | No| Callback used to return the result.<br>**err**: error code of the download failure. |
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| err | number | Yes| Error code of the download failure. For details about the error codes, see [Download Error Codes](#download-error-codes).|
**Example** **Example**
```js ```js
downloadTask.off('fail', function callBack(err) { let failCallback = (err) => {
console.info('Download task failed. Cause:' + err); console.info(`Download delete fail notification. err: ${err.message}`);
} };
); downloadTask.off('fail', failCallback);
``` ```
### delete<sup>9+</sup> ### delete<sup>9+</sup>
...@@ -1706,32 +1689,33 @@ Defines the download task configuration. ...@@ -1706,32 +1689,33 @@ Defines the download task configuration.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes| Resource URL.| | url | string | Yes| Resource URL.|
| header | Object | No| HTTPS flag header to be included in the download request.<br>The **X-TLS-Version** parameter in **header** specifies the TLS version to be used. If this parameter is not set, the CURL_SSLVERSION_TLSv1_2 version is used. Available options are as follows:<br>CURL_SSLVERSION_TLSv1_0<br>CURL_SSLVERSION_TLSv1_1<br>CURL_SSLVERSION_TLSv1_2<br>CURL_SSLVERSION_TLSv1_3<br>The **X-Cipher-List** parameter in **header** specifies the cipher suite list to be used. If this parameter is not specified, the secure cipher suite list is used. Available options are as follows:<br>- The TLS 1.2 cipher suite list includes the following ciphers:<br>TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,<br>TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,<br>TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,<br>TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,<br>TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256<br>- The TLS 1.3 cipher suite list includes the following ciphers:<br>TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256<br>- The TLS 1.3 cipher suite list adds the Chinese national cryptographic algorithm:<br>TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 | | header | Object | No| HTTPS flag header to be included in the download request.<br>The **X-TLS-Version** parameter in **header** specifies the TLS version to be used. If this parameter is not set, the CURL_SSLVERSION_TLSv1_2 version is used. Available options are as follows:<br>CURL_SSLVERSION_TLSv1_0<br>CURL_SSLVERSION_TLSv1_1<br>CURL_SSLVERSION_TLSv1_2<br>CURL_SSLVERSION_TLSv1_3<br>The **X-Cipher-List** parameter in **header** specifies the cipher suite list to be used. If this parameter is not specified, the secure cipher suite list is used. Available options are as follows:<br>- The TLS 1.2 cipher suite list includes the following ciphers:<br>TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,<br>TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,<br>TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,<br>TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,<br>TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256<br>- The TLS 1.3 cipher suite list includes the following ciphers:<br>TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256<br>- The TLS 1.3 cipher suite list adds the Chinese national cryptographic algorithm:<br>TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 |
| enableMetered | boolean | No| Whether download is allowed on a metered connection.<br>- **true**: allowed<br>- **false**: not allowed| | enableMetered | boolean | No| Whether download is allowed on a metered connection. The default value is **false**. In general cases, a mobile data connection is metered, while a Wi-Fi connection is not.<br>- **true**: allowed<br>- **false**: not allowed|
| enableRoaming | boolean | No| Whether download is allowed on a roaming network.<br>- **true**: allowed<br>- **false**: not allowed| | enableRoaming | boolean | No| Whether download is allowed on a roaming network. The default value is **false**.<br>- **true**: allowed<br>- **false**: not allowed|
| description | string | No| Description of the download session.| | description | string | No| Description of the download session.|
| filePath<sup>7+</sup> | string | No| Path where the downloaded file is stored.<br>- filePath:'/data/storage/el2/base/haps/entry/files/test.txt': Save the file to an absolute path.<br>- In the FA model, use [context](js-apis-inner-app-context.md#contextgetcachedir) to obtain the cache directory of the application, for example, **\${featureAbility.getContext().getFilesDir()}/test.txt\**, and store the file in this directory.<br>- In the stage model, use [AbilityContext](js-apis-inner-application-context.md) to obtain the file path, for example, **\${globalThis.abilityContext.tempDir}/test.txt\**, and store the file in this path.| | filePath<sup>7+</sup> | string | No| Path where the downloaded file is stored.<br>- In the FA model, use [context](js-apis-inner-app-context.md#contextgetcachedir) to obtain the cache directory of the application, for example, **\${featureAbility.getContext().getFilesDir()}/test.txt\**, and store the file in this directory.<br>- In the stage model, use [AbilityContext](js-apis-inner-application-context.md) to obtain the file path, for example, **\${globalThis.abilityContext.tempDir}/test.txt\**, and store the file in this path.|
| networkType | number | No| Network type allowed for download.<br>- NETWORK_MOBILE: 0x00000001<br>- NETWORK_WIFI: 0x00010000| | networkType | number | No| Network type allowed for download. The default value is **NETWORK_MOBILE and NETWORK_WIFI**.<br>- NETWORK_MOBILE: 0x00000001<br>- NETWORK_WIFI: 0x00010000|
| title | string | No| Download task name.| | title | string | No| Download task name.|
| background<sup>9+</sup> | boolean | No| Whether to enable the background task notification. When this parameter is enabled, the download status is displayed in the notification panel.| | background<sup>9+</sup> | boolean | No| Whether to enable background task notification so that the download status is displayed in the notification panel. The default value is false.|
## DownloadInfo<sup>7+</sup> ## DownloadInfo<sup>7+</sup>
Defines the download task information, which is the callback parameter of the [query<sup>(deprecated)</sup>](#querydeprecated-1) API. Defines the download task information, which is the callback parameter of the [getTaskInfo<sup>9+</sup>](#gettaskinfo9) API.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description| | Name| Type|Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | ------ |---------------- |
| downloadId | number | Yes| ID of the downloaded file.| | downloadId | number |Yes| ID of the download task.|
| failedReason | number | No| Cause of the download failure. The value can be any constant in [Download Error Codes](#download-error-codes).| | failedReason | number|Yes| Cause of the download failure. The value can be any constant in [Download Error Codes](#download-error-codes).|
| fileName | string | Yes| Name of the downloaded file.| | fileName | string |Yes| Name of the downloaded file.|
| filePath | string | Yes| URI of the saved file.| | filePath | string |Yes| URI of the saved file.|
| pausedReason | number | No| Cause of download pause. The value can be any constant in [Causes of Download Pause](#causes-of-download-pause).| | pausedReason | number |Yes| Cause of download pause. The value can be any constant in [Causes of Download Pause](#causes-of-download-pause).|
| status | number | Yes| Download task status code. The value can be any constant in [Download Task Status Codes](#download-task-status-codes).| | status | number |Yes| Download task status code. The value can be any constant in [Download Task Status Codes](#download-task-status-codes).|
| targetURI | string | Yes| URI of the downloaded file.| | targetURI | string |Yes| URI of the downloaded file.|
| downloadTitle | string | Yes| Download task name.| | downloadTitle | string |Yes| Name of the download task.|
| downloadTotalBytes | number | Yes| Total size of the files to download, in bytes.| | downloadTotalBytes | number |Yes| Total size of the files to download, in bytes.|
| description | string | Yes| Description of the file to download.| | description | string |Yes| Description of the download task.|
| downloadedBytes | number | Yes| Size of the files downloaded, in bytes.| | downloadedBytes | number |Yes| Size of the files downloaded, in bytes.|
<!--no_check-->
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册